Commit 945b99c
committed
fix(spec-044): autostart nil result not cached (gemini P1)
Gemini cross-review found a tray-core boot race: if the core process
starts milliseconds before the tray writes tray-autostart.json, the
first Read() sees fs.ErrNotExist and (before this fix) marked
cachedOnce=true, locking autostart_enabled to null for the whole 1h
TTL window — even after the tray subsequently wrote `true`.
Fix: on ErrNotExist and other transient I/O errors, do NOT mark
cachedOnce. Return nil this call but allow the next Read() to re-probe.
Successful reads (including malformed-JSON "known unknowable") still
cache for the full TTL.
Adds TestReadAutostart_BootRaceDoesNotPoisonCache covering the race
scenario: first read on absent file -> nil; tray writes sidecar;
second read within TTL -> picks up the new value.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 1f8dcd3 commit 945b99c
2 files changed
Lines changed: 38 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
106 | 111 | | |
107 | 112 | | |
108 | | - | |
109 | | - | |
110 | 113 | | |
111 | 114 | | |
112 | | - | |
113 | | - | |
| 115 | + | |
| 116 | + | |
114 | 117 | | |
115 | 118 | | |
116 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
117 | 147 | | |
118 | 148 | | |
119 | 149 | | |
| |||
0 commit comments