@cohortapp/agent-sdk 2.18.31 → 2.18.33

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.
@@ -100,9 +100,25 @@ export function refreshGlobalInstall(o = {}) {
100
100
  return { ok: true, action: plan.action, detail: `${plan.action === "skip" ? "skipped" : "no change"} (${plan.reason})${plan.argv && plan.action === "skip" ? `: ${plan.argv.join(" ")}` : ""}`, argv: plan.argv };
101
101
  }
102
102
  const r = exec(plan.argv[0], plan.argv.slice(1), { timeout: 180_000 });
103
- if (r.status === 0) return { ok: true, action: "install", detail: `${plan.argv.join(" ")} (${plan.reason})`, argv: plan.argv };
103
+ const was = globalVersion ? `was ${globalVersion}` : "was not installed";
104
+ if (r.status === 0) {
105
+ // POST-STATE FIRST, AND THE PRE-STATE LABELLED AS PAST.
106
+ //
107
+ // This used to interpolate `plan.reason` verbatim, which is the PRE-install
108
+ // reading — "global install is 2.18.30, agent dir is 2.18.31". On a
109
+ // SUCCESSFUL install that detail string is indistinguishable from the
110
+ // mismatch an operator is hunting, so a row whose `ok` is true reads as the
111
+ // failure. Someone auditing upgrade-result.json across a fleet for exactly
112
+ // that mismatch would flag every healthy seat.
113
+ //
114
+ // The `ok` flag was always the signal; the detail actively argued against
115
+ // it. Now the detail agrees with the flag.
116
+ return { ok: true, action: "install", detail: `${plan.argv.join(" ")} — global now ${String(o.version || "").trim()} (${was})`, argv: plan.argv };
117
+ }
104
118
  const err = String(r.stderr || "").trim().split("\n").filter(Boolean).pop() || `exit ${r.status}`;
105
- return { ok: false, action: "install", detail: `${plan.argv.join(" ")} failed: ${err} — run it by hand`, argv: plan.argv };
119
+ // On failure the actionable fact is that the global copy did NOT move, which
120
+ // the old string left the reader to infer from the absence of good news.
121
+ return { ok: false, action: "install", detail: `${plan.argv.join(" ")} failed: ${err} — global still ${globalVersion || "not installed"}; run it by hand`, argv: plan.argv };
106
122
  }
107
123
 
108
124
  export default { planGlobalRefresh, parseGlobalVersion, readGlobalVersion, refreshGlobalInstall, SDK_PACKAGE, SKIP_ENV };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cohortapp/agent-sdk",
3
- "version": "2.18.31",
3
+ "version": "2.18.33",
4
4
  "description": "Cohort Agent SDK — autonomous AI colleague runtime. Deploy senior AI colleagues on dedicated Mac minis, wired to the Cohort operating surface.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1652,6 +1652,38 @@ export function markNoticeSaid(rec, notice, now) {
1652
1652
  */
1653
1653
  async function sayOutcomeNotice(o) {
1654
1654
  const { rec, notice, text, item, kind, now } = o;
1655
+
1656
+ // ── NO OUTCOME NOTICE REACHES A DOCUMENT, AT THE CHOKEPOINT ───────────────
1657
+ //
1658
+ // 2.18.30 put this test in `settleSession`, which covered the failed,
1659
+ // timed-out and silently-exited branches and MISSED the sweep's own. A seat
1660
+ // running 2.18.30 then posted the INTERRUPTED variant onto a plan document at
1661
+ // 11:49:10Z — "was cut off part-way — the session running it stopped and a new
1662
+ // one took over" — because `sweepObligations` branch (d) emits through here
1663
+ // without passing through `settleSession` at all. Branch (c), the
1664
+ // past-every-timeout case, had the same hole.
1665
+ //
1666
+ // So the guard belongs HERE rather than at each branch. This function is the
1667
+ // single chokepoint every outcome notice passes through — three callers today
1668
+ // — and a fourth branch added later is covered by construction instead of
1669
+ // reintroducing the defect. Patching three sites and trusting the next author
1670
+ // to remember is how 2.18.30 shipped incomplete.
1671
+ //
1672
+ // WHY THE INTERRUPTED VARIANT IS THE WORST ONE TO LEAVE UNGUARDED. Its trigger
1673
+ // is `rec.daemonPid !== process.pid && !alive(rec.daemonPid)` — a daemon that
1674
+ // was replaced. An AUTOUPDATE RELAUNCH is exactly that, so every seat taking a
1675
+ // release posts one of these for whatever obligation was in flight when it
1676
+ // restarted. On a document surface that makes a release itself the trigger for
1677
+ // a comment nobody asked for, fleet-wide, once per upgrade.
1678
+ //
1679
+ // A reply is unaffected: replies go out through `deliver` directly. Only
1680
+ // OUTCOME notices pass through here, and a document never asked for one.
1681
+ if (isDocumentSurface(rec)) {
1682
+ counters.bump("assurance.notice_withheld_document", { notice, service: rec && rec.service });
1683
+ markNoticeSaid(rec, notice, now);
1684
+ return { sent: false, reason: "document-surface" };
1685
+ }
1686
+
1655
1687
  if (noticeAlreadySaid(rec, notice)) {
1656
1688
  console.log(`[assurance] ${notice} notice for ${rec.key} already delivered to ${rec.channel} — not repeating it`);
1657
1689
  counters.bump("assurance.notice_deduped", { notice, scope: "obligation" });