shraga 0.1.48 → 0.1.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shraga",
3
- "version": "0.1.48",
3
+ "version": "0.1.49",
4
4
  "description": "The teammate you delegate coding to — a self-hostable, multi-user AI coding agent web UI (Claude Code, with a pluggable engine seam).",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -181,7 +181,13 @@ export class SelfUpgrade {
181
181
  return null;
182
182
  }
183
183
  try { unlinkSync(this.o.reportFile); } catch { /* report already gone; emit anyway */ }
184
- try { unlinkSync(this.o.lockFile); } catch { /* no lock to clear */ }
184
+ // Clear the marker only if it belongs to THIS report. A boot can find a leftover report from
185
+ // the previous upgrade while a NEW one is already in flight (that is exactly the sequence when
186
+ // two upgrades run back to back) — deleting that marker would unguard the live attempt.
187
+ const marker = this.inFlight();
188
+ if (!marker || marker.target === report.target) {
189
+ try { unlinkSync(this.o.lockFile); } catch { /* no lock to clear */ }
190
+ }
185
191
 
186
192
  console.log(`${TAG} ${report.status}: ${report.detail}`);
187
193
  emitEvent('self-upgrade.finished', report);
@@ -136,10 +136,22 @@ wait_for_version() { # version timeout
136
136
 
137
137
  # A server that boots, flips the version, then dies 20s later has NOT upgraded successfully — that is
138
138
  # exactly the crash-loop an unattended upgrade must catch. Keep probing for the whole soak window.
139
+ # One dropped probe is not a crash-loop. This runs on a busy box where a single request can lose a
140
+ # 10s race (MCP mounts, a GC pause, the drain window of the restart we just did), and a zero-
141
+ # tolerance soak turns that blip into an automatic rollback of a perfectly good version — observed
142
+ # reverting 0.1.48 on feedox while the process stayed up throughout. Require CONSECUTIVE misses, so
143
+ # a real crash (which never answers again) still fails fast.
144
+ SOAK_MISS_LIMIT="${SOAK_MISS_LIMIT:-3}"
139
145
  soak() { # version seconds
140
- local deadline=$(( SECONDS + $2 ))
146
+ local deadline=$(( SECONDS + $2 )) misses=0
141
147
  while [ "$SECONDS" -lt "$deadline" ]; do
142
- reports_version "$1" || return 1
148
+ if reports_version "$1"; then
149
+ misses=0
150
+ else
151
+ misses=$(( misses + 1 ))
152
+ say "soak probe missed ($misses/$SOAK_MISS_LIMIT)"
153
+ [ "$misses" -ge "$SOAK_MISS_LIMIT" ] && return 1
154
+ fi
143
155
  sleep 5
144
156
  done
145
157
  return 0