Repository navigation
Commit 41c0295
committed
fix(editor): withdraw the preview observation on every exit path
The preview-observation rule ("the tool's own look must not authorize a
write") was applied only on saveChanges(..., "edit"). On every other
exit path the partial preview entry stayed in task.observationRegistry:
a full-file open() records the preview token with complete:false, a
rejected "update" save reloads the buffer without writing (token
unchanged, nothing forgets), and the model's next apply_diff is then
authorized by an observation the model never earned.
open() now records the token its preview wrote; reset() - reached by
every tool catch block and by revertChanges through finalizeSession -
forgets the entry while it still holds that token AND the preview's
incomplete flag. A successful publish replaces the token first, and a
model read_file records complete: true, so earned observations survive
both ways.
Regression tests: the full trigger sequence (preview -> rejected update
-> leftover -> reset withdraws), plus the two survival cases that pin
the guard's conditions (same-token complete:true from a model read
survives; a moved token survives). Negative controls, each exactly one
red: withdrawal disabled reddens the trigger test; dropping the
incomplete-flag condition reddens the same-token survival test;
dropping the token condition reddens the moved-token survival test.
Also per the trivial row: the lock-cleanup test now asserts the exact
stale-version rejection (the outcome is deterministic - open() observed
the placeholder, computeVersionToken answers the peer's token) instead
of accepting either guard verdict, and the duplicated toHaveBeenCalledWith
in the pre-preview authorization test is deduplicated.
152/152 green, eslint clean, prettier clean, tsc adds nothing beyond
the known local donor drift.1 parent bc43841 commit 41c0295
2 files changed
Lines changed: 78 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
135 | 142 | | |
136 | 143 | | |
137 | 144 | | |
| |||
207 | 214 | | |
208 | 215 | | |
209 | 216 | | |
| 217 | + | |
210 | 218 | | |
211 | 219 | | |
212 | 220 | | |
| |||
1649 | 1657 | | |
1650 | 1658 | | |
1651 | 1659 | | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
1652 | 1677 | | |
1653 | 1678 | | |
1654 | 1679 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1524 | 1524 | | |
1525 | 1525 | | |
1526 | 1526 | | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
1527 | 1576 | | |
1528 | 1577 | | |
1529 | 1578 | | |
| |||
1533 | 1582 | | |
1534 | 1583 | | |
1535 | 1584 | | |
1536 | | - | |
1537 | 1585 | | |
1538 | 1586 | | |
1539 | 1587 | | |
| |||
1860 | 1908 | | |
1861 | 1909 | | |
1862 | 1910 | | |
1863 | | - | |
1864 | | - | |
1865 | | - | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
1866 | 1915 | | |
1867 | 1916 | | |
1868 | 1917 | | |
| |||
0 commit comments