Repository navigation
Commit 6f486e8
fix(agents): write self-authored config back to the private-config overlay
The overlay only ever learned config from events this device RECEIVED. Both
fill paths are inbound-only: `insert_patch` on an `Applied` inbound event
(`personas/inbound.rs:228`) and boot hydration (`hydrate_from_retention`).
Neither fires for an event this device authored -- the relay's echo of our
own event dedupes to `Skipped` in `retain_inbound_event`, because the row is
already retained.
So the overlay stays pinned at the last received generation for the whole
session. `update_managed_agent` resolves that patch onto the disk record,
applies the user's edit, saves, and retains -- correct for ONE edit. The
SECOND edit in the same session resolves the same stale patch onto the now
fresher disk record, reverting the first edit, and publishes the reversion as
an audit-clean gen+1 successor that wins LWW. The resolve result is written
back to disk, so the revert is durable, not just in-flight.
That is Max's live gate red on a single backend: gen 3 published parallelism
19, the following rename returned 17 and published 17 as gen 4. It stands
independent of the Device-A/B attribution he retracted.
Fix: after `retain_agent_record` commits, read the just-retained kind:30179
head back out of the same connection and `insert_patch` it. One seam --
`retain_managed_agent_pending` -- covers all five writers (create, settings,
edit/rename, start, rename-rollback) with no per-caller copies and no
new-writer trap. `reconcile.rs` is untouched: `retain_agent_record` takes
`conn`+`keys` and threading `AppState` through it would drag the boot
reconcile into the diff for nothing. No new lock edge: callers already hold
`managed_agents_store_lock` and the overlay lock is taken under it, the same
order `resolved_local_record` uses. Decode is factored into
`patch_from_retained_row`, shared with boot hydration, so both learn config
through exactly one path.
Absorbing unconditionally (not gated on the retain reporting a change) keeps
the overlay from ever running ahead of retention: every insert comes from a
row read back out of the database. A missing or undecodable head leaves the
current entry alone rather than clearing it.
Coverage. `sami_second_edit_in_one_session_preserves_the_first_edit` runs the
two-edit sequence through the real retention engine, seeding gen 2 via
`retain_inbound_event` + `hydrate_from_retention` so the overlay is populated
exactly as boot populates it. Its negative control runs the same sequence
without the write-through and asserts the revert to 17, so the main assertion
cannot pass vacuously. `absorb_retained_head_leaves_the_overlay_alone_when_
there_is_no_head` pins the no-clear contract with a positive control proving
the same call DOES update on a present head.
Both behavioural tests model the helper body -- every caller is inside a
`#[tauri::command]` needing a live `AppHandle`, so deleting the production
call leaves them green (the failure mode already documented on
`write_site_resolve_guard`). Three source guards close that: exact call count
of 1, source order retain-before-absorb, and a negative control proving the
searched literals are load-bearing.
Mutants, 4/4 killed: (1) `absorb_retained_head` body no-oped -> the red test
fails with exactly the live symptom, `left: Some(17) right: Some(19)`;
(2) production call deleted -> both source guards fail; (3) production call
moved before the retain -> the order guard fails; (4) test helper's order
swapped -> the behavioural test fails.
Gate at this tree: desktop lib suite 2272 passed / 0 failed / 14 ignored,
`cargo clippy --workspace --all-targets` clean, `cargo fmt --check` clean,
`check-file-sizes` rc=0 with CHECK_FILE_SIZES_BASE pinned to the merge-base
with origin/main.
Co-authored-by: Tyler Longwell <[email protected]>
Signed-off-by: Tyler Longwell <[email protected]>1 parent aa39d72 commit 6f486e8
4 files changed
Lines changed: 371 additions & 11 deletions
File tree
- desktop/src-tauri/src
- commands
- managed_agents
- reconcile
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
42 | 52 | | |
43 | 53 | | |
44 | 54 | | |
| |||
52 | 62 | | |
53 | 63 | | |
54 | 64 | | |
55 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
56 | 71 | | |
57 | 72 | | |
58 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
216 | 254 | | |
217 | 255 | | |
218 | 256 | | |
| |||
437 | 475 | | |
438 | 476 | | |
439 | 477 | | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
440 | 495 | | |
441 | 496 | | |
442 | 497 | | |
| |||
454 | 509 | | |
455 | 510 | | |
456 | 511 | | |
457 | | - | |
458 | | - | |
| 512 | + | |
459 | 513 | | |
460 | 514 | | |
461 | 515 | | |
| |||
465 | 519 | | |
466 | 520 | | |
467 | 521 | | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
| 522 | + | |
476 | 523 | | |
477 | 524 | | |
478 | 525 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
| 558 | + | |
558 | 559 | | |
0 commit comments