@cohortapp/agent-sdk 2.18.24 → 2.18.25
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/bin/maestro.mjs +39 -4
- package/lib/assurance/first-reply.mjs +61 -0
- package/package.json +1 -1
- package/scripts/daemon/assurance.mjs +31 -3
package/bin/maestro.mjs
CHANGED
|
@@ -932,13 +932,31 @@ function isGitRepo(cwd) {
|
|
|
932
932
|
|
|
933
933
|
// Build a Set of repo-relative paths that are dirty (modified, added, untracked).
|
|
934
934
|
// Single git invocation is much faster than per-file checks.
|
|
935
|
+
//
|
|
936
|
+
// RETURNS null WHEN IT CANNOT TELL — never an empty Set.
|
|
937
|
+
//
|
|
938
|
+
// This used to `catch { }` and return the empty Set it had built, with a
|
|
939
|
+
// comment claiming "caller will fall back to caution mode". There was no such
|
|
940
|
+
// fallback: an empty Set is precisely the shape of "I checked, and nothing is
|
|
941
|
+
// dirty", so every local edit classified as pristine-and-overwritable. The
|
|
942
|
+
// caller's real caution signal is `null` — the value it already uses for "not
|
|
943
|
+
// a git repo", which preserves everything.
|
|
944
|
+
//
|
|
945
|
+
// It was reachable, and it was reached. `execFileSync` defaults to a 1 MiB
|
|
946
|
+
// maxBuffer; a repo with a large untracked tree (a node_modules, a build dir,
|
|
947
|
+
// a log directory) overflows it, git is killed with ENOBUFS, and the upgrade
|
|
948
|
+
// then overwrote hand-applied patches on a seat while reporting every stage
|
|
949
|
+
// ok, with empty backup and incoming directories. maxBuffer is raised to the
|
|
950
|
+
// same 256 MB `scripts/fleet/rollout.mjs` uses for exactly this reason — but
|
|
951
|
+
// the size is the mitigation and the null is the fix, because any git failure
|
|
952
|
+
// at all (a lock, a corrupt index, git missing from PATH) had the same effect.
|
|
935
953
|
function dirtyPathSet(cwd) {
|
|
936
954
|
const set = new Set();
|
|
937
955
|
try {
|
|
938
956
|
const out = execFileSync(
|
|
939
957
|
"git",
|
|
940
958
|
["status", "--porcelain=v1", "-z", "--untracked-files=all"],
|
|
941
|
-
{ cwd, encoding: "utf-8" }
|
|
959
|
+
{ cwd, encoding: "utf-8", maxBuffer: 256 * 1024 * 1024 }
|
|
942
960
|
);
|
|
943
961
|
// -z separates records with NUL; each record is "XY path" (no quoting).
|
|
944
962
|
// For renames (R/C) the format is "R newpath\0oldpath\0" — we only care
|
|
@@ -950,9 +968,12 @@ function dirtyPathSet(cwd) {
|
|
|
950
968
|
// Anything in porcelain output is non-clean by definition.
|
|
951
969
|
if (status !== " ") set.add(path);
|
|
952
970
|
}
|
|
953
|
-
} catch {
|
|
954
|
-
//
|
|
971
|
+
} catch (e) {
|
|
972
|
+
// CANNOT TELL. Say so; do not answer "nothing is dirty".
|
|
973
|
+
dirtyPathSet.lastError = (e && (e.code || e.message)) || "unknown";
|
|
974
|
+
return null;
|
|
955
975
|
}
|
|
976
|
+
dirtyPathSet.lastError = null;
|
|
956
977
|
return set;
|
|
957
978
|
}
|
|
958
979
|
|
|
@@ -1240,6 +1261,13 @@ Per-file behaviour:
|
|
|
1240
1261
|
}
|
|
1241
1262
|
|
|
1242
1263
|
const dirty = inGit ? dirtyPathSet(cwd) : null;
|
|
1264
|
+
if (inGit && dirty === null) {
|
|
1265
|
+
// Same posture as "not a git repo", and said just as loudly. Silence here
|
|
1266
|
+
// is what made the data loss invisible: every stage reported ok.
|
|
1267
|
+
warn(`Could not read local modifications from git (${dirtyPathSet.lastError}).`);
|
|
1268
|
+
warn("All existing files will be treated as locally modified and preserved.");
|
|
1269
|
+
warn("Prune is disabled for this run. Use --force-overwrite to override.");
|
|
1270
|
+
}
|
|
1243
1271
|
const ignorePatterns = loadMaestroignore(cwd);
|
|
1244
1272
|
if (ignorePatterns) {
|
|
1245
1273
|
log(`.maestroignore loaded (${ignorePatterns.length} pattern${ignorePatterns.length === 1 ? "" : "s"})`);
|
|
@@ -1313,7 +1341,9 @@ Per-file behaviour:
|
|
|
1313
1341
|
}
|
|
1314
1342
|
|
|
1315
1343
|
// Case 4: locally modified? Determine via git dirty set.
|
|
1316
|
-
|
|
1344
|
+
// `dirty` is null both outside a repo and when git could not be read.
|
|
1345
|
+
// Both mean "unprovable", and unprovable must preserve.
|
|
1346
|
+
const locallyModified = dirty ? dirty.has(repoRel) : true;
|
|
1317
1347
|
|
|
1318
1348
|
if (locallyModified && !flags.forceOverwrite) {
|
|
1319
1349
|
counts.preserved++;
|
|
@@ -1382,6 +1412,11 @@ Per-file behaviour:
|
|
|
1382
1412
|
log("Prune skipped (--no-prune): upstream-deleted files left in place.");
|
|
1383
1413
|
} else if (!inGit) {
|
|
1384
1414
|
warn("Prune skipped: not a git repo, so pristine framework files can't be told from yours.");
|
|
1415
|
+
} else if (!dirty) {
|
|
1416
|
+
// Prune deletes files on the strength of "git says this is tracked and
|
|
1417
|
+
// clean". With no readable git status there is no such strength, and the
|
|
1418
|
+
// failure mode is deleting an operator's work.
|
|
1419
|
+
warn(`Prune skipped: could not read git status (${dirtyPathSet.lastError}), so pristine files can't be told from yours.`);
|
|
1385
1420
|
} else if (!priorManifest) {
|
|
1386
1421
|
log("Prune skipped: no shipped-manifest yet, so framework files can't be told from your own.");
|
|
1387
1422
|
log(`Recording one now (${SHIPPED_MANIFEST_REL}); prune takes effect from the next upgrade.`);
|
|
@@ -483,3 +483,64 @@ export function isAgentStatusNotice(body) {
|
|
|
483
483
|
}
|
|
484
484
|
return false;
|
|
485
485
|
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* A SESSION SAYING IT HAS ALREADY ANSWERED THIS ONE.
|
|
489
|
+
*
|
|
490
|
+
* The silent-success rescue (`assurance.settleSession`) exists to hand a waiting
|
|
491
|
+
* requester the result their session produced but failed to send. It reads
|
|
492
|
+
* "exited 0 having sent nothing" as exactly one state — the answer got stuck on
|
|
493
|
+
* the way out — when there are two. The second is a session that read the item,
|
|
494
|
+
* recognised it as something it had ALREADY replied to, and declined to reply
|
|
495
|
+
* twice.
|
|
496
|
+
*
|
|
497
|
+
* Published, that second state is nonsense in the room. Measured, 2026-09-30
|
|
498
|
+
* 18:21:49Z, one seat into a shared engineering channel:
|
|
499
|
+
*
|
|
500
|
+
* Here's where I got to:
|
|
501
|
+
* Archived — this is a duplicate delivery of the same audit I already
|
|
502
|
+
* responded to in-channel this session. Logged to
|
|
503
|
+
* `logs/audit/2026-09-30-actions.jsonl`, no second response sent.
|
|
504
|
+
*
|
|
505
|
+
* Every word was true. The seat HAD answered, and declining to answer twice is
|
|
506
|
+
* the owner's standing instruction ("sometimes a reply isn't needed"). The
|
|
507
|
+
* rescue overrode that judgement and posted the reasoning, addressed to nobody,
|
|
508
|
+
* citing a path no colleague can open.
|
|
509
|
+
*
|
|
510
|
+
* WHY NOT SIMPLY "THE SESSION SAID IT SENT NOTHING". That was this function's
|
|
511
|
+
* first cut and it was wrong — three existing tests caught it, which is what
|
|
512
|
+
* they are for. "Nothing was sent." is the marker for BOTH states: the live
|
|
513
|
+
* sighting that created the rescue in the first place is a session whose final
|
|
514
|
+
* text read "I reviewed the three failing checks and pushed fixes for two. The
|
|
515
|
+
* third needs a decision from you. Nothing was sent." There the human is owed
|
|
516
|
+
* the result and suppressing it loses a decision they must make. The sentence
|
|
517
|
+
* does not separate the states; ALREADY-ANSWERED does, because it is the only
|
|
518
|
+
* one of the two in which the ask is genuinely discharged.
|
|
519
|
+
*
|
|
520
|
+
* Deliberately NOT matched: "no action needed", "nothing to do", "already
|
|
521
|
+
* handled". Those describe the WORK, not the REPLY — a session that says the
|
|
522
|
+
* work needs nothing may still owe the asker that sentence.
|
|
523
|
+
*/
|
|
524
|
+
const ALREADY_ANSWERED_PATTERNS = Object.freeze([
|
|
525
|
+
/\balready (?:responded|replied|answered)\b/i,
|
|
526
|
+
/\bduplicate (?:delivery|copy|of the same|of an?)\b/i,
|
|
527
|
+
/\b(?:responded|replied|answered) to (?:this|it|the same) (?:already|earlier|in[- ]channel)\b/i,
|
|
528
|
+
/\bsame (?:item|message|request|ask) (?:i|we) (?:already |have already )?(?:answered|replied to|responded to)\b/i,
|
|
529
|
+
]);
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Does this session's final text state that it had ALREADY replied to this
|
|
533
|
+
* item, so the ask is discharged and a rescue would be a second voice?
|
|
534
|
+
*
|
|
535
|
+
* Judged over the WHOLE text, not per paragraph: the statement is routinely a
|
|
536
|
+
* mid-sentence clause ("…duplicate delivery of the same audit I already
|
|
537
|
+
* responded to in-channel this session.").
|
|
538
|
+
*
|
|
539
|
+
* @param {unknown} finalText the session's own end-of-turn text
|
|
540
|
+
* @returns {boolean}
|
|
541
|
+
*/
|
|
542
|
+
export function isAlreadyAnsweredElsewhere(finalText) {
|
|
543
|
+
const t = String(finalText == null ? "" : finalText);
|
|
544
|
+
if (!t.trim()) return false;
|
|
545
|
+
return ALREADY_ANSWERED_PATTERNS.some((re) => re.test(t));
|
|
546
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cohortapp/agent-sdk",
|
|
3
|
-
"version": "2.18.
|
|
3
|
+
"version": "2.18.25",
|
|
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": {
|
|
@@ -98,7 +98,7 @@ import {
|
|
|
98
98
|
noticeRejection,
|
|
99
99
|
fallbackNotice,
|
|
100
100
|
} from "../../lib/assurance/notice-voice.mjs";
|
|
101
|
-
import { isRetiredFirstReply, firstReplyShape, REACTIONS } from "../../lib/assurance/first-reply.mjs";
|
|
101
|
+
import { isRetiredFirstReply, firstReplyShape, REACTIONS, isAlreadyAnsweredElsewhere } from "../../lib/assurance/first-reply.mjs";
|
|
102
102
|
// The unit of acknowledgement is the CONVERSATION, not the message: four
|
|
103
103
|
// messages in a row earn ONE first response that was written with all four in
|
|
104
104
|
// front of it. `groupIntoBatches` + `batchVerdict` decide WHEN and WHICH;
|
|
@@ -1409,8 +1409,8 @@ export function classifyFailure(o = {}) {
|
|
|
1409
1409
|
//
|
|
1410
1410
|
// Measured on seat A028 that day: ten asks, each one capped, each one told a
|
|
1411
1411
|
// bare error. The owner read the room and diagnosed the cap by eye
|
|
1412
|
-
// ("looks like
|
|
1413
|
-
// was withholding what the machine already had.
|
|
1412
|
+
// ("looks like that seat has hit its limit") — which is the tell that the
|
|
1413
|
+
// notice was withholding what the machine already had.
|
|
1414
1414
|
//
|
|
1415
1415
|
// PRECEDENCE, both directions, because USAGE_LIMIT_RE matches the bare words
|
|
1416
1416
|
// "limit reached" and would otherwise steal two neighbours:
|
|
@@ -1978,6 +1978,34 @@ export async function settleSession(a = {}) {
|
|
|
1978
1978
|
return { spoke: false, text: null, verdict: "silent-success", willRetry: false };
|
|
1979
1979
|
}
|
|
1980
1980
|
const finalText = safeResultText(a.stdout);
|
|
1981
|
+
|
|
1982
|
+
// A SESSION THAT CHOSE SILENCE HAS NOT FAILED TO SPEAK.
|
|
1983
|
+
//
|
|
1984
|
+
// This rescue reads "exited 0 having sent nothing" as one state — the
|
|
1985
|
+
// answer got stuck on the way out. There are two, and the second is a
|
|
1986
|
+
// session that recognised the item as one it had ALREADY replied to.
|
|
1987
|
+
// Publishing that one posts the seat's own reasoning into a room, addressed
|
|
1988
|
+
// to nobody. Measured on 2026-09-30 18:21:49Z, one seat into a shared
|
|
1989
|
+
// engineering channel: "Archived — this is a duplicate delivery of the same
|
|
1990
|
+
// audit I already responded to in-channel this session. Logged to
|
|
1991
|
+
// logs/audit/…jsonl, no second response sent." Every word of that was true,
|
|
1992
|
+
// the seat HAD already answered, and declining to answer twice is the
|
|
1993
|
+
// owner's standing instruction — which this rescue then overrode.
|
|
1994
|
+
//
|
|
1995
|
+
// The debt still closes. Silence was the session's answer, so the ask is
|
|
1996
|
+
// discharged, not abandoned; only the narration is withheld. Same shape as
|
|
1997
|
+
// the ambient-surface branch above, and a distinct note + counter so the
|
|
1998
|
+
// difference stays visible to an operator sweeping outcomes.
|
|
1999
|
+
if (isAlreadyAnsweredElsewhere(finalText)) {
|
|
2000
|
+
closeObligation(a.key, {
|
|
2001
|
+
outcome: "answered",
|
|
2002
|
+
now,
|
|
2003
|
+
note: "session exited 0 stating it had already answered this item; second narration withheld",
|
|
2004
|
+
});
|
|
2005
|
+
counters.bump("assurance.silent_success_already_answered", { service: rec.service });
|
|
2006
|
+
return { spoke: false, text: null, verdict: "silent-success", willRetry: false };
|
|
2007
|
+
}
|
|
2008
|
+
|
|
1981
2009
|
const text = composeSilentSuccess(rec, { finalText });
|
|
1982
2010
|
const res = await send(item, text, { kind: "reply", idempotencySuffix: `rescue-${rec.attempts || 0}` });
|
|
1983
2011
|
closeObligation(a.key, {
|