fix: 教我做——訊息時間是 0(記下時間之前的訊息)不算指名哪一回合,照字找
審查(e755e58)的 P2:手機對記下時間之前的訊息送 at: 0,taught_turn 拿 0 去比,任何沒記時間的回合 都對得上,按一則跟它無關的舊訊息也會學到最新那個沒記時間的回合。0 當成沒給時間,走照字的那條路。 已驗證: memory 測試補兩句(at 0+同樣的字找得到、at 0+不同的字找不到);拿掉修正時 a_message_with_a_file_and_an_older_turn_can_be_taught 失敗,放回後逐位元組相同; 全部 cargo test(不帶金鑰、DOCKER_HOST 指到不存在)通過;clippy -D warnings 乾淨 未驗證: 真的資料夾裡升級前的回合(只有單元測試) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha5sXAsDLzxz6UZJgoC
This commit is contained in:
parent
e755e5878d
commit
7adcb17278
|
|
@ -213,6 +213,8 @@ fn plain_words(t: &str) -> String {
|
|||
/// the trail had the time (0), it is the latest turn started by the same words. `starts`: the
|
||||
/// turns' first lines (store::turn_starts). Ok: (that turn, the words the person typed).
|
||||
pub fn taught_turn(prompt: &str, at: Option<i64>, starts: &[crate::oplog::Record]) -> Result<(String, String), String> {
|
||||
// A message from before times were kept says `at: 0`: that names no turn — go by its words.
|
||||
let at = at.filter(|t| *t > 0);
|
||||
let key: String = plain_words(prompt).chars().take(40).collect();
|
||||
let same_words = |p: &crate::oplog::Prompt| plain_words(crate::attach::typed_part(&p.text)).chars().take(40).collect::<String>() == key;
|
||||
let latest = |ok: &dyn Fn(&crate::oplog::Prompt) -> bool| {
|
||||
|
|
@ -1519,6 +1521,10 @@ mod tests {
|
|||
assert_eq!(taught_turn("看這張", None, &starts).map(|t| t.0), Ok("with-file".into()), "by its words too");
|
||||
assert_eq!(taught_turn("以前的簽到", Some(400), &starts).map(|t| t.0), Ok("old".into()), "a turn from before the time was kept");
|
||||
assert!(taught_turn("以前的", Some(400), &starts).is_err(), "…by all its words, not a part");
|
||||
// A message from before times were kept comes with `at: 0`: found by its words, never as
|
||||
// whichever untimed turn is newest.
|
||||
assert_eq!(taught_turn("以前的簽到", Some(0), &starts).map(|t| t.0), Ok("old".into()));
|
||||
assert!(taught_turn("完全不同的一句話", Some(0), &starts).is_err(), "at 0 names no turn");
|
||||
}
|
||||
#[test]
|
||||
fn remember_tells_the_same_thing_from_another_fact() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue