pi-goal-list-loop-audit 0.38.43 → 0.38.45
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/CHANGELOG.md +27 -0
- package/INSTALL.md +20 -0
- package/docs/INDEX.md +1 -1
- package/extensions/approval-render-store.ts +17 -2
- package/extensions/completion-summary.ts +53 -17
- package/extensions/glla-update-check.ts +117 -0
- package/extensions/glla-version.ts +95 -3
- package/extensions/goal-commands.ts +1 -1
- package/extensions/goal-loop-display.ts +20 -4
- package/extensions/goal-recovery.ts +5 -1
- package/extensions/loops/goal-activation.ts +5 -0
- package/extensions/loops/goal-ui.ts +15 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.38.45 — full-project audit pass: 16 fixes across version, summary, and approval paths (2026-09-10)
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **Update-check spawn hardening (HIGH):** `refreshUpdateCheck` now subscribes to async `error` (a missing/broken npm crashed the host unhandled), detaches via `unref`, ignores stderr/stdin, and caches only version-shaped stdout tokens — registry noise can no longer poison the sidecar.
|
|
8
|
+
- **`/glla version` honesty (HIGH):** no staleness claim when the running version is unreadable (previously printed a false "up to date"); both surfaces share one strict sidecar reader so the status tail and the command cannot disagree.
|
|
9
|
+
- **Recorded-facts Next survives (HIGH):** `withoutStaleNext` exempts the concrete "review the durable record at …" fallback Next that the `/review/i` clause ate, leaving fallback approval chats actionless.
|
|
10
|
+
- **No per-contact spawn storm:** the TTL skip uses the raw sidecar read, so a future-dated cache (clock skew) suppresses the spawn instead of causing one per command contact.
|
|
11
|
+
- **Approval re-render after delivery:** delivered history dedups exact duplicates only (repeated settlements never double-notify); a genuine re-approval with new verdict lines queues fresh — content, not goalId, decides.
|
|
12
|
+
- **SessionDir-aware sidecar path:** `updateCheckPath` resolves via `resolveGllaStateDir` instead of hardcoding `cwd/.pi-glla`.
|
|
13
|
+
- **String-safety:** `clipSummaryValue` is code-point-safe (no more split surrogate pairs); `chatSafeDetailValue` converges nested machine-path groups to a fixpoint; label segmentation uses last-occurrence search so a label named inside a value no longer steals later segments.
|
|
14
|
+
- **Verdict tally uses its clock:** `auditorVerdictTally(now)` suppresses future `lastAt` instead of printing "0s ago"; dead `void now` and dead `readUpdateCheck` import removed; `recovery-resume.json` documented as a reserved hook with no current producer.
|
|
15
|
+
- **Pins:** spawn-error swallow, token validation, future-cache skip, prerelease compare, unknown-version silence, recorded-facts survival, nested-husk convergence, surrogate safety, last-restatement-wins, delivery-then-reapproval, paused-branch tail, future-verdict silence.
|
|
16
|
+
|
|
17
|
+
## 0.38.44 — stale-version surfacing: running version in the status line (2026-09-10)
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- **Stale-session visibility (field 20260909_161057):** a live session rendered the pre-0.38.39 summary voice while the repo shipped 0.38.42 with nothing visible saying so. The status line now always carries the running version (`glla: … · v0.38.44`) on every branch; when the registry is ahead it nudges (`· update vX available`).
|
|
22
|
+
- **Cached staleness check:** new `extensions/glla-update-check.ts` — the render reads the `.pi-glla/update-check.json` sidecar only and never touches the network; a throttled (24h TTL) fire-and-forget `npm view` refresh rides the command/lifecycle contact gate and fails silently offline.
|
|
23
|
+
- **`/glla version` names staleness:** appends `Registry latest` plus the concrete update path (`pi install npm:pi-goal-list-loop-audit@latest` then `/reload`) when the sidecar proves the session stale; legacy three lines unchanged with no cache.
|
|
24
|
+
- **INSTALL.md `Updating` section:** documents the nudge, the update command, and the `/reload`-every-session requirement. Pure version/compare helpers live in `glla-version.ts` (no import cycle); the display module keeps zero runtime imports via a precomputed `versionTail` extra.
|
|
25
|
+
|
|
26
|
+
### Verification
|
|
27
|
+
|
|
28
|
+
- Full `release:check` 0 failures; `tsc --noEmit` clean.
|
|
29
|
+
|
|
3
30
|
## 0.38.43 — ship merged PR #50, drop orphaned helpers (2026-09-10)
|
|
4
31
|
|
|
5
32
|
### Fixed
|
package/INSTALL.md
CHANGED
|
@@ -29,6 +29,26 @@ GLLA loads into new pi sessions. If pi is already open, reload that session:
|
|
|
29
29
|
/reload
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
## Updating
|
|
33
|
+
|
|
34
|
+
The status line always shows the running version (`glla: … · v0.38.44`).
|
|
35
|
+
When the npm registry is ahead, it also nudges:
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
glla: … · v0.38.43 · update v0.38.44 available
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The nudge comes from a daily sidecar check (`.pi-glla/update-check.json`),
|
|
42
|
+
refreshed on command contact and never blocking a turn. To update:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pi install npm:pi-goal-list-loop-audit@latest
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Then `/reload` every open pi session — a session keeps running the
|
|
49
|
+
version it loaded with until reloaded. `/glla version` says whether the
|
|
50
|
+
current session is stale and repeats the update command.
|
|
51
|
+
|
|
32
52
|
### Recommended companions
|
|
33
53
|
|
|
34
54
|
The structured-question companion is recommended for the intended drafting
|
package/docs/INDEX.md
CHANGED
|
@@ -18,7 +18,7 @@ For shipped docs, the relevant entry points are:
|
|
|
18
18
|
failback; v0.35.9 hardened cross-version npm tarball checks; v0.35.10
|
|
19
19
|
handles multi-entry npm dry-run reports; v0.35.11 accepts both npm report
|
|
20
20
|
shapes; v0.35.12 supports npm 12's keyed pack reports; v0.35.13 fixes stale-API recovery loops.
|
|
21
|
-
v0.35.14–v0.38.
|
|
21
|
+
v0.35.14–v0.38.45 continue through the supervisor freeze (`/glla pause`),
|
|
22
22
|
load hold, auditor picker parity, Windows launch fix, zombie-watchdog
|
|
23
23
|
subagent carve-out, due-wait backstop, the `/glla agents` visibility panel,
|
|
24
24
|
durable state-root selection, blank-until-resume auditor context, frozen
|
|
@@ -90,13 +90,28 @@ export function persistApprovalRender(cwd: string, render: {
|
|
|
90
90
|
}): boolean {
|
|
91
91
|
const at = nowIso();
|
|
92
92
|
const existing = readRenders(cwd);
|
|
93
|
-
|
|
93
|
+
// v0.38.30 truncation (also code-point-safe): compare what WOULD be
|
|
94
|
+
// stored, so an identical re-persist of long lines still dedups.
|
|
95
|
+
const incomingLines = render.chatLines.slice(0, MAX_RENDER_CHAT_LINES)
|
|
96
|
+
.map((line) => [...line].slice(0, MAX_RENDER_LINE_CHARS).join(""));
|
|
97
|
+
// Dedup has two layers. (1) An UNDELIVERED entry for the goal means a
|
|
98
|
+
// render is already queued — a second persist before delivery changes
|
|
99
|
+
// nothing. (2) v0.38.45 audit: delivered history dedups only EXACT
|
|
100
|
+
// duplicates (a repeated settlement re-persisting identical lines must
|
|
101
|
+
// not double-notify) — but a re-approval carries new verdict lines, and
|
|
102
|
+
// dropping those silently hid an archive-failure retry's chat summary
|
|
103
|
+
// while the caller believed it queued. Content, not goalId, decides.
|
|
104
|
+
if (existing.some((entry) => !entry.deliveredAt && entry.goalId === render.goalId)) return true;
|
|
105
|
+
const sameLines = (a: string[], b: string[]): boolean =>
|
|
106
|
+
a.length === b.length && a.every((line, i) => line === b[i]);
|
|
107
|
+
if (existing.some((entry) =>
|
|
108
|
+
entry.deliveredAt && entry.goalId === render.goalId && sameLines(entry.chatLines, incomingLines))) return true;
|
|
94
109
|
const entry: PendingApprovalRender = {
|
|
95
110
|
goalId: render.goalId,
|
|
96
111
|
// v0.38.30 audit: code-point truncation (char slice split surrogate
|
|
97
112
|
// pairs) + bounded chat lines (the 20-entry cap never bound bytes).
|
|
98
113
|
objective: [...render.objective].slice(0, 300).join(""),
|
|
99
|
-
chatLines:
|
|
114
|
+
chatLines: incomingLines,
|
|
100
115
|
createdAt: at,
|
|
101
116
|
};
|
|
102
117
|
// The cap trims DELIVERED history only: undelivered renders are never
|
|
@@ -90,32 +90,53 @@ export function isUsefulCompletionSummary(text: string | undefined): boolean {
|
|
|
90
90
|
export function clipSummaryValue(value: string, limit: number): string {
|
|
91
91
|
const clean = value.replace(/\s+/g, " ").trim();
|
|
92
92
|
const capped = Number.isFinite(limit) ? Math.max(8, Math.floor(limit)) : 72;
|
|
93
|
-
|
|
94
|
-
const
|
|
93
|
+
// v0.38.45 audit: code-point-safe — UTF-16 slice split surrogate pairs.
|
|
94
|
+
const units = [...clean];
|
|
95
|
+
if (units.length <= capped) return clean;
|
|
96
|
+
const headUnits = units.slice(0, capped - 1);
|
|
97
|
+
const head = headUnits.join("");
|
|
95
98
|
const floor = Math.max(16, Math.floor((capped - 1) * 0.4));
|
|
96
99
|
let boundary = -1;
|
|
97
|
-
|
|
98
|
-
if (/[,;:·—–(+[\[]
|
|
99
|
-
}
|
|
100
|
+
headUnits.forEach((unit, i) => {
|
|
101
|
+
if (/[,;:·—–(+[\[]/u.test(unit)) boundary = i;
|
|
102
|
+
});
|
|
100
103
|
if (boundary >= floor) {
|
|
101
|
-
const cut =
|
|
102
|
-
if (cut.length >= Math.min(floor, 16)) return `${cut}…`;
|
|
104
|
+
const cut = headUnits.slice(0, boundary).join("").replace(/[,;:·—–(+[\[\s]+$/u, "");
|
|
105
|
+
if ([...cut].length >= Math.min(floor, 16)) return `${cut}…`;
|
|
103
106
|
}
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
let space = -1;
|
|
108
|
+
headUnits.forEach((unit, i) => {
|
|
109
|
+
if (unit === " ") space = i;
|
|
110
|
+
});
|
|
111
|
+
const kept = (space > capped / 2 ? headUnits.slice(0, space).join("") : head)
|
|
106
112
|
.trimEnd()
|
|
107
113
|
.replace(/[,;:·—–(+\[]$/u, "");
|
|
108
114
|
return `${kept}…`;
|
|
109
115
|
}
|
|
110
116
|
|
|
117
|
+
/** v0.38.45 audit: LAST-occurrence label search — first-occurrence
|
|
118
|
+
* indexOf let a label named inside an earlier label's VALUE steal the
|
|
119
|
+
* segmentation of every later label ("Outcome: see Tests: x. Tests: y"
|
|
120
|
+
* read Outcome as "see"). The last restatement wins, which also favors
|
|
121
|
+
* the final wording when an agent echoes the skeleton twice. Residual
|
|
122
|
+
* ambiguity (a single skeleton whose value names a later label once)
|
|
123
|
+
* is accepted: values keep their text, only the boundary moves. */
|
|
124
|
+
function labelPositions(lower: string): Array<{ label: string; start: number }> {
|
|
125
|
+
const positions: Array<{ label: string; start: number }> = [];
|
|
126
|
+
for (const label of COMPLETION_SUMMARY_LABELS) {
|
|
127
|
+
const start = lower.lastIndexOf(label.toLowerCase());
|
|
128
|
+
if (start < 0) continue;
|
|
129
|
+
positions.push({ label, start });
|
|
130
|
+
}
|
|
131
|
+
return positions;
|
|
132
|
+
}
|
|
133
|
+
|
|
111
134
|
export function compactCompletionSummary(text: string | undefined, maxValueLength = 72): string {
|
|
112
135
|
const source = completionSummaryBody(text ?? "").replace(/\s+/g, " ").trim();
|
|
113
136
|
if (!source) return "not recorded";
|
|
114
137
|
const lower = source.toLowerCase();
|
|
115
138
|
const limit = Number.isFinite(maxValueLength) ? Math.max(8, Math.floor(maxValueLength)) : 72;
|
|
116
|
-
const positions =
|
|
117
|
-
.map((label) => ({ label, start: lower.indexOf(label.toLowerCase()) }))
|
|
118
|
-
.filter((entry) => entry.start >= 0);
|
|
139
|
+
const positions = labelPositions(lower);
|
|
119
140
|
const parts = COMPLETION_SUMMARY_LABELS.map((label) => {
|
|
120
141
|
const current = positions.find((entry) => entry.label === label);
|
|
121
142
|
const name = label.slice(0, -1);
|
|
@@ -159,7 +180,11 @@ export interface HumanCompletionBrief {
|
|
|
159
180
|
* the durable archive keeps the full text. Falls back to the original
|
|
160
181
|
* when stripping would empty the value. */
|
|
161
182
|
export function chatSafeDetailValue(value: string): string {
|
|
162
|
-
|
|
183
|
+
// v0.38.45 audit: loop the innermost-group strip to a fixpoint
|
|
184
|
+
// (bounded) — a single pass left nested husks like "(log )" behind.
|
|
185
|
+
let withoutGroups = value;
|
|
186
|
+
for (let pass = 0; pass < 5; pass++) {
|
|
187
|
+
const next = withoutGroups.replace(/\([^()]*\)/g, (group) => {
|
|
163
188
|
// A parenthesized group that carries nothing but stripped tokens and
|
|
164
189
|
// receipt words is machine packaging — drop the whole group so no
|
|
165
190
|
// `( tarball )` husk survives. Groups with real words stay verbatim.
|
|
@@ -169,7 +194,10 @@ export function chatSafeDetailValue(value: string): string {
|
|
|
169
194
|
.replace(/\S+\.tgz\b/g, "")
|
|
170
195
|
.replace(/\btarballs?\b|\blogs?\b/gi, "");
|
|
171
196
|
return /[a-z]/i.test(inner) ? group : "";
|
|
172
|
-
|
|
197
|
+
});
|
|
198
|
+
if (next === withoutGroups) break;
|
|
199
|
+
withoutGroups = next;
|
|
200
|
+
}
|
|
173
201
|
const stripped = withoutGroups
|
|
174
202
|
.replace(/(?:\/var)?\/tmp\/\S+/g, "")
|
|
175
203
|
.replace(/\btarballs?\s+\S+\.tgz\b/gi, "")
|
|
@@ -215,6 +243,10 @@ export function humanCompletionBrief(
|
|
|
215
243
|
* approval`, …) still drop, but the first concrete action survives as
|
|
216
244
|
* the closing bullet. The full six-label record stays in the archive. */
|
|
217
245
|
const STALE_NEXT_PATTERN = /auditor|verdict|approv|audit|settl|review/i;
|
|
246
|
+
/** The recorded-facts fallback Next is concrete (`review the durable
|
|
247
|
+
* record at …`) and must survive the stale-Next filter (v0.38.45 audit:
|
|
248
|
+
* /review/i ate it, leaving fallback approval chats with no next action). */
|
|
249
|
+
const RECORDED_FACTS_NEXT_PATTERN = /review the durable/i;
|
|
218
250
|
export function withoutStaleNext(details: string[] | undefined): string[] {
|
|
219
251
|
const kept: string[] = [];
|
|
220
252
|
let actionKept = false;
|
|
@@ -223,6 +255,12 @@ export function withoutStaleNext(details: string[] | undefined): string[] {
|
|
|
223
255
|
kept.push(detail);
|
|
224
256
|
continue;
|
|
225
257
|
}
|
|
258
|
+
if (RECORDED_FACTS_NEXT_PATTERN.test(detail)) {
|
|
259
|
+
if (actionKept) continue;
|
|
260
|
+
actionKept = true;
|
|
261
|
+
kept.push(detail);
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
226
264
|
if (STALE_NEXT_PATTERN.test(detail)) continue;
|
|
227
265
|
if (actionKept) continue;
|
|
228
266
|
actionKept = true;
|
|
@@ -394,9 +432,7 @@ export function buildTerminalApprovalRender(input: TerminalApprovalRenderInput):
|
|
|
394
432
|
export function completionSummaryLines(text: string | undefined, maxValueLength = 240, lineWidth?: number): string[] {
|
|
395
433
|
const source = completionSummaryBody(text ?? "").replace(/\s+/g, " ").trim();
|
|
396
434
|
const lower = source.toLowerCase();
|
|
397
|
-
const positions =
|
|
398
|
-
.map((label) => ({ label, start: lower.indexOf(label.toLowerCase()) }))
|
|
399
|
-
.filter((entry) => entry.start >= 0);
|
|
435
|
+
const positions = labelPositions(lower);
|
|
400
436
|
return COMPLETION_SUMMARY_LABELS.map((label) => {
|
|
401
437
|
const name = label.slice(0, -1);
|
|
402
438
|
const current = positions.find((entry) => entry.label === label);
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import {
|
|
5
|
+
compareVersions,
|
|
6
|
+
GLLA_PACKAGE_NAME,
|
|
7
|
+
isVersionLike,
|
|
8
|
+
readUpdateCheck,
|
|
9
|
+
readUpdateCheckRaw,
|
|
10
|
+
updateCheckPath,
|
|
11
|
+
type UpdateCheckCache,
|
|
12
|
+
} from "./glla-version.js";
|
|
13
|
+
|
|
14
|
+
export { compareVersions, readUpdateCheck, updateCheckPath };
|
|
15
|
+
export type { UpdateCheckCache };
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* v0.38.44 (field 20260909_161057): a live session rendered the
|
|
19
|
+
* pre-0.38.39 summary voice while the repo shipped 0.38.42 — nothing
|
|
20
|
+
* visible told the session it runs old GLLA. Shipped fixes only reach
|
|
21
|
+
* sessions that know they are stale, so the status line carries the
|
|
22
|
+
* running version plus a nudge when the registry is ahead.
|
|
23
|
+
*
|
|
24
|
+
* Render discipline: the status/card render reads the sidecar cache ONLY
|
|
25
|
+
* and never touches the network. A throttled fire-and-forget refresh
|
|
26
|
+
* rides the command/lifecycle contact gate; failures (offline, slow
|
|
27
|
+
* registry, missing npm) leave the old cache in place and never surface.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
export const UPDATE_CHECK_TTL_MS = 24 * 60 * 60 * 1_000;
|
|
31
|
+
export const UPDATE_CHECK_TIMEOUT_MS = 15_000;
|
|
32
|
+
|
|
33
|
+
export interface SpawnedRefreshChild {
|
|
34
|
+
on(event: "close", listener: (code: number | null) => void): void;
|
|
35
|
+
on(event: "error", listener: (err: unknown) => void): void;
|
|
36
|
+
unref?: () => void;
|
|
37
|
+
stdout: { on(event: "data", listener: (chunk: Buffer) => void): void };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type SpawnFn = (
|
|
41
|
+
command: string,
|
|
42
|
+
args: string[],
|
|
43
|
+
options: { timeout: number; stdio?: Array<"ignore" | "pipe"> },
|
|
44
|
+
) => SpawnedRefreshChild;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Throttled fire-and-forget refresh: returns immediately in every case.
|
|
48
|
+
* Skips when the cache is within TTL; otherwise shells `npm view` with a
|
|
49
|
+
* bounded timeout and rewrites the cache on success. Never throws — an
|
|
50
|
+
* offline session simply keeps rendering without a nudge.
|
|
51
|
+
* v0.38.45 audit: the spawned child carries an `error` listener (a
|
|
52
|
+
* missing/broken npm emits async `error`, which the outer try/catch
|
|
53
|
+
* cannot catch and which crashes the host unhandled), detaches via
|
|
54
|
+
* unref, and ignores stderr/stdin; only version-shaped stdout tokens
|
|
55
|
+
* are cached. The TTL skip uses the RAW read so a future-dated cache
|
|
56
|
+
* (clock skew) suppresses the spawn instead of causing one per contact.
|
|
57
|
+
*/
|
|
58
|
+
export function refreshUpdateCheck(
|
|
59
|
+
cwd: string,
|
|
60
|
+
now = Date.now(),
|
|
61
|
+
spawnFn: SpawnFn = spawn as unknown as SpawnFn,
|
|
62
|
+
): void {
|
|
63
|
+
try {
|
|
64
|
+
const cached = readUpdateCheckRaw(cwd);
|
|
65
|
+
if (cached && now - cached.checkedAt < UPDATE_CHECK_TTL_MS) return;
|
|
66
|
+
const child = spawnFn("npm", ["view", GLLA_PACKAGE_NAME, "version"], {
|
|
67
|
+
timeout: UPDATE_CHECK_TIMEOUT_MS,
|
|
68
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
69
|
+
});
|
|
70
|
+
// A missing/broken npm emits async `error`, not a sync throw and
|
|
71
|
+
// not a nonzero close — without this listener the host crashes.
|
|
72
|
+
child.on("error", () => {
|
|
73
|
+
// Fail-silent by design: keep rendering without a nudge.
|
|
74
|
+
});
|
|
75
|
+
if (typeof child.unref === "function") child.unref();
|
|
76
|
+
let out = "";
|
|
77
|
+
child.stdout.on("data", (chunk) => {
|
|
78
|
+
out += chunk.toString();
|
|
79
|
+
if (out.length > 256) out = out.slice(-256);
|
|
80
|
+
});
|
|
81
|
+
child.on("close", (code) => {
|
|
82
|
+
try {
|
|
83
|
+
if (code !== 0) return;
|
|
84
|
+
const latest = out.trim().split(/\s+/).pop() ?? "";
|
|
85
|
+
if (!isVersionLike(latest)) return;
|
|
86
|
+
const dir = path.dirname(updateCheckPath(cwd));
|
|
87
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
88
|
+
fs.writeFileSync(updateCheckPath(cwd), JSON.stringify({ latest: latest.trim(), checkedAt: Date.now() }));
|
|
89
|
+
} catch {
|
|
90
|
+
// Cache write failure is invisible by design.
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
} catch {
|
|
94
|
+
// Spawn failure (no npm, no shell) is invisible by design.
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The status-tail segment: `· v<running>` always (so the running
|
|
100
|
+
* version is visible on every branch), plus `· update v<latest>
|
|
101
|
+
* available` only when the cache proves the registry is ahead.
|
|
102
|
+
* Empty string when the running version is unknown.
|
|
103
|
+
*/
|
|
104
|
+
export function buildVersionTail(running: string, latest: string | null): string {
|
|
105
|
+
if (!running || running === "unknown") return "";
|
|
106
|
+
const nudge = latest ? staleUpdateNudge(running, { latest, checkedAt: 0 }) : null;
|
|
107
|
+
return `· v${running}${nudge ? ` · ${nudge}` : ""}`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** The nudge proper: null when there is nothing to say (no cache yet,
|
|
111
|
+
* unparseable versions, or already current). "unknown" running versions
|
|
112
|
+
* never nudge — a damaged manifest must not cry wolf. */
|
|
113
|
+
export function staleUpdateNudge(running: string, cached: UpdateCheckCache | null): string | null {
|
|
114
|
+
if (!cached || running === "unknown") return null;
|
|
115
|
+
if (compareVersions(cached.latest, running) > 0) return `update v${cached.latest} available`;
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
@@ -1,14 +1,82 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { resolveGllaStateDir } from "./glla-state-root.js";
|
|
4
5
|
|
|
5
6
|
export const GLLA_PACKAGE_NAME = "pi-goal-list-loop-audit";
|
|
6
7
|
|
|
8
|
+
/** Sidecar path shared with the update check (kept here so both
|
|
9
|
+
* glla-version and glla-update-check resolve it without a cycle).
|
|
10
|
+
* v0.38.45 audit: root-aware — sessionDir mode keeps the sidecar beside
|
|
11
|
+
* every other state file instead of splitting it under cwd. */
|
|
12
|
+
export function updateCheckPath(cwd: string): string {
|
|
13
|
+
return path.join(resolveGllaStateDir(cwd), "update-check.json");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Numeric semver-ish compare: 1 when a > b, -1 when a < b, 0 when equal
|
|
17
|
+
* or unparseable. Pure — shared by the version command and the nudge.
|
|
18
|
+
* v0.38.45 audit: strictly numeric segments — parseInt equated
|
|
19
|
+
* prereleases (`3-beta`→3), so a prerelease running build never nudged. */
|
|
20
|
+
export function compareVersions(a: string, b: string): number {
|
|
21
|
+
const numParts = (s: string): number[] | null => {
|
|
22
|
+
const parts = s.trim().replace(/^v/, "").split(".");
|
|
23
|
+
if (parts.some((part) => !/^\d+$/.test(part))) return null;
|
|
24
|
+
return parts.map((part) => Number.parseInt(part, 10));
|
|
25
|
+
};
|
|
26
|
+
const pa = numParts(a);
|
|
27
|
+
const pb = numParts(b);
|
|
28
|
+
if (!pa || !pb) return 0;
|
|
29
|
+
const len = Math.max(pa.length, pb.length);
|
|
30
|
+
for (let i = 0; i < len; i++) {
|
|
31
|
+
const x = pa[i] ?? 0;
|
|
32
|
+
const y = pb[i] ?? 0;
|
|
33
|
+
if (x > y) return 1;
|
|
34
|
+
if (x < y) return -1;
|
|
35
|
+
}
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
7
39
|
const PACKAGE_JSON_PATH = path.resolve(
|
|
8
40
|
path.dirname(fileURLToPath(import.meta.url)),
|
|
9
41
|
"../package.json",
|
|
10
42
|
);
|
|
11
43
|
|
|
44
|
+
export interface UpdateCheckCache {
|
|
45
|
+
latest: string;
|
|
46
|
+
checkedAt: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Raw sidecar read: null when missing/unreadable/malformed. Accepts
|
|
50
|
+
* future-dated entries — the refresh skip-check uses this so one skewed
|
|
51
|
+
* clock does not become a per-contact spawn storm (v0.38.45 audit). */
|
|
52
|
+
export function readUpdateCheckRaw(cwd: string): UpdateCheckCache | null {
|
|
53
|
+
try {
|
|
54
|
+
const parsed: unknown = JSON.parse(fs.readFileSync(updateCheckPath(cwd), "utf8"));
|
|
55
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
56
|
+
const record = parsed as Record<string, unknown>;
|
|
57
|
+
if (typeof record.latest !== "string" || !record.latest.trim()) return null;
|
|
58
|
+
if (typeof record.checkedAt !== "number" || !Number.isFinite(record.checkedAt)) return null;
|
|
59
|
+
return { latest: record.latest.trim(), checkedAt: record.checkedAt };
|
|
60
|
+
} catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Strict sidecar read for render surfaces: additionally rejects
|
|
66
|
+
* future-dated entries (clock skew must read as unknown, never fresh). */
|
|
67
|
+
export function readUpdateCheck(cwd: string): UpdateCheckCache | null {
|
|
68
|
+
const raw = readUpdateCheckRaw(cwd);
|
|
69
|
+
if (!raw) return null;
|
|
70
|
+
if (raw.checkedAt > Date.now() + 60_000) return null;
|
|
71
|
+
return raw;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** npm-version-shaped tokens only — the refresh caches stdout, so
|
|
75
|
+
* registry noise must never poison the sidecar (v0.38.45 audit). */
|
|
76
|
+
export function isVersionLike(token: string): boolean {
|
|
77
|
+
return /^v?\d+\.\d+\.\d+([\-+][\w.]+)?$/.test(token.trim());
|
|
78
|
+
}
|
|
79
|
+
|
|
12
80
|
export interface GllaVersionInfo {
|
|
13
81
|
name: string;
|
|
14
82
|
version: string;
|
|
@@ -38,10 +106,34 @@ export function readGllaVersionInfo(): GllaVersionInfo {
|
|
|
38
106
|
return { name: GLLA_PACKAGE_NAME, version: "unknown" };
|
|
39
107
|
}
|
|
40
108
|
|
|
41
|
-
export function formatGllaVersion(info: GllaVersionInfo = readGllaVersionInfo()): string {
|
|
42
|
-
|
|
109
|
+
export function formatGllaVersion(cwd?: string, info: GllaVersionInfo = readGllaVersionInfo()): string {
|
|
110
|
+
const lines = [
|
|
43
111
|
`${info.name} v${info.version}`,
|
|
44
112
|
"Installed package version.",
|
|
45
113
|
`Compare with registry latest: npm view ${info.name} version`,
|
|
46
|
-
]
|
|
114
|
+
];
|
|
115
|
+
// v0.38.44 (field 20260909_161057): when the update sidecar has a
|
|
116
|
+
// cached registry latest, say whether this session is stale and how
|
|
117
|
+
// to fix it. No cache (offline / never checked) keeps the legacy
|
|
118
|
+
// three lines — absence of evidence is not evidence of freshness.
|
|
119
|
+
// v0.38.45 audit: the strict shared reader (same validation as the
|
|
120
|
+
// status tail, so the two surfaces cannot disagree), and no staleness
|
|
121
|
+
// claim at all when the running version is unreadable — "unknown"
|
|
122
|
+
// compared equal and printed a false "up to date".
|
|
123
|
+
if (cwd && info.version !== "unknown") {
|
|
124
|
+
try {
|
|
125
|
+
const cached = readUpdateCheck(cwd);
|
|
126
|
+
if (cached) {
|
|
127
|
+
lines.push(`Registry latest: v${cached.latest}.`);
|
|
128
|
+
lines.push(
|
|
129
|
+
compareVersions(cached.latest, info.version) > 0
|
|
130
|
+
? `This session is stale — update: pi install npm:${info.name}@latest then /reload.`
|
|
131
|
+
: "This session is up to date.",
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
} catch {
|
|
135
|
+
// Sidecar read failure keeps the legacy output.
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return lines.join("\n");
|
|
47
139
|
}
|
|
@@ -2385,7 +2385,7 @@ function cmdAudits(args: string, ctx: ExtensionContext): void {
|
|
|
2385
2385
|
// version lookup next to the command surface makes an installed extension
|
|
2386
2386
|
// identify itself even when its host session is stale or no live goal exists.
|
|
2387
2387
|
function cmdGllaVersion(ctx: ExtensionContext): void {
|
|
2388
|
-
ctx.ui.notify(formatGllaVersion(), "info");
|
|
2388
|
+
ctx.ui.notify(formatGllaVersion(ctx.cwd), "info");
|
|
2389
2389
|
}
|
|
2390
2390
|
|
|
2391
2391
|
// v0.35.72: /glla bug — lightweight failure capture that never touches
|
|
@@ -216,6 +216,12 @@ export interface WidgetExtras {
|
|
|
216
216
|
auditorProgressSignals?: boolean;
|
|
217
217
|
/** Effective global main-model backup order for truthful recovery HUDs. */
|
|
218
218
|
mainModelFallbacks?: string[];
|
|
219
|
+
/** v0.38.44 (field 20260909_161057): precomputed status-tail version
|
|
220
|
+
* segment (`· v<running>` plus the update nudge when the cache proves
|
|
221
|
+
* the registry is ahead). Resolved at render contact by the caller —
|
|
222
|
+
* this module keeps zero runtime imports, so the pure compare/nudge
|
|
223
|
+
* logic lives in glla-update-check.ts. */
|
|
224
|
+
versionTail?: string;
|
|
219
225
|
/** Truthful model-selection provenance for the active goal card/footer. */
|
|
220
226
|
modelProvenance?: ModelProvenanceDisplay;
|
|
221
227
|
/** Deterministic durable-vs-defer decision surface. Kept optional so the
|
|
@@ -603,7 +609,6 @@ export interface AuditorVerdictTally {
|
|
|
603
609
|
lastLabel: string | null;
|
|
604
610
|
}
|
|
605
611
|
export function auditorVerdictTally(history: Goal["auditHistory"], now = Date.now()): AuditorVerdictTally {
|
|
606
|
-
void now;
|
|
607
612
|
const entries = Array.isArray(history) ? history : [];
|
|
608
613
|
let approvals = 0;
|
|
609
614
|
let disapprovals = 0;
|
|
@@ -614,11 +619,15 @@ export function auditorVerdictTally(history: Goal["auditHistory"], now = Date.no
|
|
|
614
619
|
}
|
|
615
620
|
const last = entries[entries.length - 1];
|
|
616
621
|
const lastMs = last ? Date.parse(last.at) : Number.NaN;
|
|
622
|
+
// v0.38.45 audit: `now` earns its parameter slot — a future lastAt
|
|
623
|
+
// (clock skew) suppresses the age instead of printing "0s ago" via
|
|
624
|
+
// fmtElapsed's clamp, matching auditorLastActivity's handling.
|
|
625
|
+
const lastOk = last && Number.isFinite(lastMs) && (lastMs as number) <= now;
|
|
617
626
|
return {
|
|
618
627
|
total: entries.length,
|
|
619
628
|
approvals,
|
|
620
629
|
disapprovals,
|
|
621
|
-
lastAt:
|
|
630
|
+
lastAt: lastOk ? (lastMs as number) : null,
|
|
622
631
|
lastLabel: last ? auditVerdictLabel(last) : null,
|
|
623
632
|
};
|
|
624
633
|
}
|
|
@@ -1137,8 +1146,15 @@ export function buildStatusText(state: State, audit?: AuditDisplayProgress | nul
|
|
|
1137
1146
|
const withAgentSummary = base && extras?.agents?.line
|
|
1138
1147
|
? `${base} · ${extras.agents.line.replace(/^●\s*/, "")}`
|
|
1139
1148
|
: base;
|
|
1140
|
-
|
|
1141
|
-
|
|
1149
|
+
// v0.38.44 (field 20260909_161057): the running version rides the tail
|
|
1150
|
+
// of EVERY branch — a stale session must be visible at a glance, not
|
|
1151
|
+
// discoverable via a command. The update nudge appears only when the
|
|
1152
|
+
// sidecar cache proves the registry is ahead; render never touches the
|
|
1153
|
+
// network (refresh rides the command-contact gate).
|
|
1154
|
+
const versionTail = extras?.versionTail ? ` ${extras.versionTail}` : "";
|
|
1155
|
+
const withVersion = withAgentSummary && versionTail ? `${withAgentSummary}${versionTail}` : withAgentSummary;
|
|
1156
|
+
if (!withVersion || typeof state.supervisorPausedAt !== "number") return truncateStatusToWidth(withVersion, width);
|
|
1157
|
+
return truncateStatusToWidth(withVersion.replace(/^glla:/, `glla: ${paint(theme, "warning", "⏸ supervisor")} ·`), width);
|
|
1142
1158
|
}
|
|
1143
1159
|
|
|
1144
1160
|
/** Status-line width budget — the auditing/paused/loop branches concatenate
|
|
@@ -52,7 +52,11 @@ const RECOVERY_RESUME_FRESH_MS = 300_000;
|
|
|
52
52
|
|
|
53
53
|
/** v0.34.13: consume the sidecar marker on session restore. Single-use,
|
|
54
54
|
* freshness-bounded — a stale marker from an abandoned recovery must not
|
|
55
|
-
* surprise-resume a later session.
|
|
55
|
+
* surprise-resume a later session.
|
|
56
|
+
* v0.38.45 audit: no production writer plants this marker today (repo-wide
|
|
57
|
+
* grep: only tests do) — the restore-gate disjuncts below read it as a
|
|
58
|
+
* reserved hook, always false live. Do not remove the reads: an older or
|
|
59
|
+
* foreign producer dropping this file must still consent a resume. */
|
|
56
60
|
export function consumeRecoveryResume(cwd: string): boolean {
|
|
57
61
|
try {
|
|
58
62
|
const p = path.join(piGlaDir(cwd), RECOVERY_RESUME_MARKER);
|
|
@@ -125,6 +125,7 @@ isGoalRevisionCurrent,
|
|
|
125
125
|
type ListItem,
|
|
126
126
|
} from "../goal-loop-core.js";
|
|
127
127
|
import { replayUndeliveredApprovalRenders } from "../approval-render-store.js";
|
|
128
|
+
import { refreshUpdateCheck } from "../glla-update-check.js"; // v0.38.44 stale-version nudge
|
|
128
129
|
import {
|
|
129
130
|
createContinuationDispatch,
|
|
130
131
|
dispatchMatchesOwner,
|
|
@@ -739,6 +740,10 @@ export function __testOnlyClassifyStaleContinuation(content: string, cwd: string
|
|
|
739
740
|
/** Commands and lifecycle contacts share the same ownership and delivery gates. */
|
|
740
741
|
function replayApprovalSummariesOnContact(ctx: ExtensionContext): void {
|
|
741
742
|
if (shouldSkipApprovalRenderReplay(ctx)) return;
|
|
743
|
+
// v0.38.44 (field 20260909_161057): the update-sidecar refresh rides
|
|
744
|
+
// the same contact gate — throttled + fire-and-forget inside, so this
|
|
745
|
+
// never blocks the turn and never surfaces on failure.
|
|
746
|
+
refreshUpdateCheck(ctx.cwd);
|
|
742
747
|
replayUndeliveredApprovalRenders(ctx, (entry) => sendTerminalCompletionNotice(ctx, {
|
|
743
748
|
goalId: entry.goalId, outcome: entry.objective, details: [], chatLines: entry.chatLines,
|
|
744
749
|
}));
|
|
@@ -259,6 +259,8 @@ import {
|
|
|
259
259
|
type ModelPickItem,
|
|
260
260
|
} from "../model-picker.js";
|
|
261
261
|
import { consumeRecoveryResume } from "../goal-recovery.js"; // decomposition step 3 (v0.34.111)
|
|
262
|
+
import { buildVersionTail, readUpdateCheck } from "../glla-update-check.js"; // v0.38.44 version tail
|
|
263
|
+
import { readGllaVersionInfo } from "../glla-version.js"; // v0.38.44 version tail
|
|
262
264
|
import {
|
|
263
265
|
createGoalHeartbeat,
|
|
264
266
|
endSubagentHangProbe,
|
|
@@ -500,6 +502,14 @@ let lastUIRenderAt = 0;
|
|
|
500
502
|
let lastUIRenderContext: ExtensionContext | null = null;
|
|
501
503
|
let lastUIStatusText: string | undefined;
|
|
502
504
|
let lastUIWidgetKey: string | undefined;
|
|
505
|
+
// v0.38.44: the running version is fixed for the process lifetime (the
|
|
506
|
+
// loaded code IS the version), so resolve package.json once instead of on
|
|
507
|
+
// every render tick.
|
|
508
|
+
let cachedRunningGllaVersion: string | null = null;
|
|
509
|
+
function runningGllaVersion(): string {
|
|
510
|
+
if (cachedRunningGllaVersion === null) cachedRunningGllaVersion = readGllaVersionInfo().version;
|
|
511
|
+
return cachedRunningGllaVersion;
|
|
512
|
+
}
|
|
503
513
|
|
|
504
514
|
/**
|
|
505
515
|
* Completion-auditor progress is ephemeral, but it still has an owner. A
|
|
@@ -826,6 +836,11 @@ function refreshUI(ctx: ExtensionContext, force = false): void {
|
|
|
826
836
|
modelProvenance,
|
|
827
837
|
...(durableDeferRecommendation ? { durableDeferRecommendation } : {}),
|
|
828
838
|
...(lastAuditorQuietStretch ? { auditorQuietStretch: lastAuditorQuietStretch } : {}),
|
|
839
|
+
// v0.38.44 (field 20260909_161057): precomputed version tail for
|
|
840
|
+
// the status line — package.json running version + update-sidecar
|
|
841
|
+
// latest. Render never touches the network; the sidecar refresh
|
|
842
|
+
// rides the command-contact gate.
|
|
843
|
+
versionTail: buildVersionTail(runningGllaVersion(), readUpdateCheck(ctx.cwd)?.latest ?? null),
|
|
829
844
|
};
|
|
830
845
|
const statusText = buildStatusText(state, latestAuditProgress, now, theme, extras, width);
|
|
831
846
|
const widgetLines = buildWidgetLines(state, latestAuditProgress, now, theme, width, extras);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-goal-list-loop-audit",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.45",
|
|
4
4
|
"description": "Mission control for autonomous pi: interview-drafted goals, an audited task queue, and forever-loops (metric, spec, project-audit) that run for hours. A detached extension-less auditor process re-verifies every completion with raw evidence without holding the main pi turn; confirmed drafts, decision pauses and consent gates keep you in charge.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"author": "dracon",
|