A monorepo management tool for the agentic ages

cache

+16 -26
+14 -25
lib/cache.ml
··· 1 - type cache_header = { 2 - config_path : string; 3 - config_mtime : float; 4 - } 1 + (** Config file modification time - if this changes, config was edited *) 2 + type cache_header = float 5 3 6 - type cache_key = { 7 - repos : (string * string) list; (* (name, path) pairs *) 8 - repo_mtimes : float list; (* mtime of each repo's packages directory *) 9 - } 4 + (** Repo content modification times - if any change, repo contents changed *) 5 + type cache_key = float list 10 6 11 7 let cache_filename = "repo_index.cache" 12 8 ··· 21 17 get_file_mtime packages_dir 22 18 23 19 let make_cache_key (repos : Config.repo_config list) = 24 - let repo_list = 25 - List.filter_map 26 - (fun (r : Config.repo_config) -> 27 - match r.source with 28 - | Config.Local path -> Some (r.name, path) 29 - | Config.Remote _ -> None) 30 - repos 31 - in 32 - let repo_mtimes = 33 - List.map (fun (_, path) -> get_repo_mtime path) repo_list 34 - in 35 - { repos = repo_list; repo_mtimes } 20 + List.filter_map 21 + (fun (r : Config.repo_config) -> 22 + match r.source with 23 + | Config.Local path -> Some (get_repo_mtime path) 24 + | Config.Remote _ -> None) 25 + repos 36 26 37 27 let cache_path cache_dir = 38 28 Eio.Path.(cache_dir / cache_filename) ··· 63 53 ~finally:(fun () -> close_in ic) 64 54 (fun () -> 65 55 let header : cache_header = Marshal.from_channel ic in 66 - if header <> expected_header then None 56 + if not (Float.equal header expected_header) then None 67 57 else 68 58 let key : cache_key = Marshal.from_channel ic in 69 - if key <> expected_key then None 59 + if not (List.equal Float.equal key expected_key) then None 70 60 else 71 61 let index : Repo_index.t = Marshal.from_channel ic in 72 62 Some index) ··· 93 83 Format.eprintf "Warning: Could not serialize cache: %s@." msg 94 84 95 85 let rec load_index ~cache_dir ~config_path = 96 - let config_mtime = get_file_mtime config_path in 97 - let header = { config_path; config_mtime } in 86 + let header : cache_header = get_file_mtime config_path in 98 87 99 88 (* Quick check: has config file changed? *) 100 89 let cached_header = read_cache_header cache_dir in 101 90 let config_unchanged = 102 91 match cached_header with 103 - | Some h -> h = header 92 + | Some h -> Float.equal h header 104 93 | None -> false 105 94 in 106 95
+2 -1
unpac.opam
··· 6 6 authors: ["Anil Madhavapeddy"] 7 7 license: "ISC" 8 8 depends: [ 9 - "dune" {>= "3.0"} 9 + "dune" {>= "3.20"} 10 10 "ocaml" {>= "5.1.0"} 11 11 "cmdliner" {>= "1.2.0"} 12 12 "eio_main" {>= "1.0"} ··· 34 34 "@doc" {with-doc} 35 35 ] 36 36 ] 37 + x-maintenance-intent: ["(latest)"]