ad580dbcce93
warn about incoming flagged saves on steal as the document asks (3.0.20, codex review pending)
- time
- 2026-09-23 22:30 UTC · 2 weeks ago
- machine
- koh2
- agent
- claude-opus-5-5
- session
- koh 3 review fixes
- parent
- ab6e63d2bc60
↓ koh-ad580dbc.tar.gzatlas at this save
files changed5 files
VERSION+1 −1src/cli/cmd_steal.v+13 −0src/sync/steal.v+9 −0src/sync/sync_test.v+31 −0v.mod+1 −1src/cli/cmd_steal.v+13 −0
@@ -8,6 +8,7 @@88 99 import json1010 import os11+import src.events1112 import src.fmt1213 import src.history1314 import src.remote@@ -59,6 +60,7 @@5960 kept_mine: report.kept_mine6061 head: report.head6162 offer_failed: !offered63+ flagged: report.flagged.map(it.save_id)6264 }))6365 return 06466 }@@ -75,6 +77,13 @@7577 note('kept mine for ${fmt.plural(report.kept_mine, 'file')}')7678 }7779 }80+ for flag in report.flagged {81+ warn('[${flag.save_id}] came in flagged${if flag.reason != '' {82+ ' — ${flag.reason}'83+ } else {84+ ''85+ }}')86+ }7887 if report.clashes.len > 0 {7988 note('${report.clashes.len} changed on both machines: ${report.clashes.join(', ')}')8089 }@@ -179,6 +188,9 @@179188 }180189 ok('fetched "${name}" into ${target}')181190 note('${fetched.saves.len} saves at [${fetched.head}]')191+ for save_id in events.flagged_ids(store) or { []string{} } {192+ warn('[${save_id}] came in flagged')193+ }182194 return 0183195 }184196 @@ -197,4 +209,5 @@197209 kept_mine int198210 head string199211 offer_failed bool212+ flagged []string200213 }src/sync/steal.v+9 −0
@@ -53,6 +53,7 @@5353 replayed int5454 removed int5555 head string56+ flagged []events.Flag // incoming saves that are flagged5657 }5758 5859 pub const dirty_tree = 'save or checkpoint first — steal needs a clean tree'@@ -120,6 +121,14 @@120121 })121122 store.commit() or { return err }122123 report.head = final.id124+ flags := events.latest_flags(store)!125+ for record in fetched.saves {126+ if flag := flags[record.id] {127+ if flag.flagged {128+ report.flagged << flag129+ }130+ }131+ }123132 124133 if head := head_before {125134 if final.id == head.id {src/sync/sync_test.v+31 −0
@@ -994,3 +994,34 @@994994 steal(b, mut backend, StealOptions{})!995995 assert os.read_file(os.join_path(b_root, 'notes.txt'))! == 'from A\n'996996 }997+998+// The document asks steal to warn about every incoming flagged save, so the999+// report names them.1000+fn test_steal_reports_incoming_flagged_saves() {1001+ base := scratch('flag_warn')!1002+ defer {1003+ os.rmdir_all(base) or {}1004+ }1005+ mut backend := remote.new_folder(os.join_path(base, 'remote'))!1006+ mut a := open_repo(machine('flag_warn_a')!)!1007+ defer {1008+ a.close()1009+ }1010+ mut b := open_repo(machine('flag_warn_b')!)!1011+ defer {1012+ b.close()1013+ }1014+ put(a.root, 'a.txt', 'one\n')!1015+ commit(a, 'fine')!1016+ offer_now(a, mut backend)!1017+ join(b, mut backend)!1018+ put(a.root, 'a.txt', 'two\n')!1019+ suspect := commit(a, 'suspect')!1020+ put(a.root, 'a.txt', 'three\n')!1021+ commit(a, 'also fine')!1022+ events.flag(a, suspect.id, 'broke the build')!1023+ offer_now(a, mut backend)!1024+ report := steal_now(b, mut backend)!1025+ assert report.flagged.map(it.save_id) == [suspect.id]1026+ assert report.flagged[0].reason == 'broke the build'1027+}v.mod+1 −1
@@ -1,6 +1,6 @@11 Module {22 name: 'koh3'3- version: '3.0.19'3+ version: '3.0.20'44 description: 'One SQLite file per repo, one line of history.'55 license: 'MIT'66 }