|
27 | 27 | (declare-extern fram.rt/coord-retract [Int String String String Int -> String]) |
28 | 28 | (declare-extern fram.rt/coord-port [-> Int]) |
29 | 29 | (declare-extern fram.rt/coord-status [Int -> String]) |
| 30 | +(declare-extern fram.rt/coord-live-claims [Int String -> (Vec k/Claim)]) |
30 | 31 | (declare-extern fram.rt/coord-watch [Int -> Nil]) |
31 | 32 | (declare-extern fram.rt/history [String String -> Nil]) |
32 | 33 | (declare-extern fram.rt/parse-edn [String -> Any]) |
|
36 | 37 | (defn- short-id [te :- String] :- String |
37 | 38 | (if (str/starts-with? te "@") (subs te 1) te)) |
38 | 39 |
|
| 40 | +;; --- daemon-first read (thread 019f2190) ------------------------------------- |
| 41 | +;; The current claim set: the coordinator's warm live view when a daemon serves |
| 42 | +;; THIS log (served in fold emission order — the :claims op contract — so |
| 43 | +;; downstream output is byte-identical to the cold fold's), else the cold fold. |
| 44 | +;; [] from coord-live-claims is the whole capability handshake — daemon down / |
| 45 | +;; old daemon / different log. |
| 46 | +(defn- live-claims [log :- String] :- (Vec k/Claim) |
| 47 | + (let [warm (fram.rt/coord-live-claims (fram.rt/coord-port) log)] |
| 48 | + (if (empty? warm) |
| 49 | + (:claims (fold/fold (fram.rt/read-log log))) |
| 50 | + warm))) |
| 51 | + |
39 | 52 | ;; --- claim-set signatures (divergence detection for the import/export guards) - |
40 | 53 | (defn- claim-sig [c :- k/Claim] :- String (str (:l c) "|" (:p c) "|" (:r c))) |
41 | 54 | (defn- sig-set [claims :- (Vec k/Claim)] :- (Vec String) (vec (sort (mapv claim-sig claims)))) |
|
114 | 127 | ;; (it would match every thread), and an ambiguous prefix lists the candidates and |
115 | 128 | ;; picks none. |
116 | 129 | (defn cmd-show [log :- String id :- String] :- Nil |
117 | | - (let [f (fold/fold (fram.rt/read-log log)) |
118 | | - claims (:claims f) |
| 130 | + (let [claims (live-claims log) |
119 | 131 | te (str "@" id) |
120 | 132 | exact (k/q-by-l claims te) |
121 | 133 | matches (if (or (not (empty? exact)) (str/blank? id)) |
122 | 134 | [] |
| 135 | + ;; prefix resolution over the INDEX: (k/thread-ids claims) is a |
| 136 | + ;; flat one-per-subject scan — O(subjects × claims), ~2s on the |
| 137 | + ;; 10.7k-claim log — while thread-ids-i over build-index is |
| 138 | + ;; O(claims). Same subjects, same uniq claim order, so the match |
| 139 | + ;; list (and the ambiguous-prefix listing) is byte-identical. |
123 | 140 | (filterv (fn [t :- String] :- Bool (str/starts-with? (short-id t) id)) |
124 | | - (k/thread-ids claims)))] |
| 141 | + (k/thread-ids-i (k/build-index claims))))] |
125 | 142 | (cond |
126 | 143 | [(not (empty? exact)) |
127 | 144 | (doseq [c exact] (println (str " " (:p c) " " (:r c))))] |
|
0 commit comments