@hearsay-tools/squawk 0.18.0-pr3656.6620 → 0.18.0-pr3656.6628
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/dist/ci-wait/tools.d.ts +4 -4
- package/dist/server/checkout.d.ts +1 -1
- package/dist/server/health-cache.d.ts +39 -0
- package/dist/server/health-cache.js +66 -0
- package/dist/server/health-cache.js.map +1 -0
- package/dist/server/server.d.ts +176 -176
- package/dist/server/server.js +17 -63
- package/dist/server/server.js.map +1 -1
- package/package.json +4 -4
- package/scripts/measure-transcript-facts-health.mjs +1 -12
package/dist/ci-wait/tools.d.ts
CHANGED
|
@@ -248,6 +248,10 @@ export declare function invokeScheduleTaskTool(input: unknown): Promise<{
|
|
|
248
248
|
}[];
|
|
249
249
|
isError: boolean;
|
|
250
250
|
details: {
|
|
251
|
+
ok: false;
|
|
252
|
+
code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
|
|
253
|
+
message: string;
|
|
254
|
+
} | {
|
|
251
255
|
ok: true;
|
|
252
256
|
task: {
|
|
253
257
|
id: string;
|
|
@@ -259,10 +263,6 @@ export declare function invokeScheduleTaskTool(input: unknown): Promise<{
|
|
|
259
263
|
url?: string | undefined;
|
|
260
264
|
};
|
|
261
265
|
note: string;
|
|
262
|
-
} | {
|
|
263
|
-
ok: false;
|
|
264
|
-
code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
|
|
265
|
-
message: string;
|
|
266
266
|
};
|
|
267
267
|
}>;
|
|
268
268
|
export declare function invokeScheduledTasksTool(input: unknown): Promise<{
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side health cache (stale-while-revalidate). The snapshot reads Git and workspace state,
|
|
3
|
+
* and each Git read spawns a child process on the server loop. Paying that on the browser's FIRST
|
|
4
|
+
* `GET /api/health` is the few-seconds-blank the cockpit showed at load, so the live server computes
|
|
5
|
+
* the snapshot at its own pace: the GET and the WS `health` topic serve the cached value at once and
|
|
6
|
+
* revalidate behind the response, and the cache is pre-warmed at boot.
|
|
7
|
+
*/
|
|
8
|
+
/** How often a read starts a revalidation. */
|
|
9
|
+
export declare const HEALTH_TTL_MS = 5000;
|
|
10
|
+
/**
|
|
11
|
+
* The staleness CEILING, a different job from the TTL. The TTL decides how often a revalidation
|
|
12
|
+
* starts; on its own it bounds nothing, because the revalidation is fire-and-forget. While a cockpit
|
|
13
|
+
* holds the `health` topic the publisher's interval keeps the cache warm — but the normal state of a
|
|
14
|
+
* background `hsq serve` is NO subscriber, and then nothing refreshes the cache at all: the next GET,
|
|
15
|
+
* an hour later, would answer with the boot pre-warm's payload. `repo.branch` going stale there is
|
|
16
|
+
* hearsay-tools/cezarion#369, so past this age the read waits for the compute.
|
|
17
|
+
*/
|
|
18
|
+
export declare const HEALTH_MAX_STALE_MS = 60000;
|
|
19
|
+
export interface HealthCache<T> {
|
|
20
|
+
/** Compute a new snapshot. Concurrent callers share ONE compute rather than racing two. */
|
|
21
|
+
refresh(): Promise<T>;
|
|
22
|
+
/**
|
|
23
|
+
* The cached payload, revalidated behind the read when stale, awaited when too old or absent.
|
|
24
|
+
* `serveCached` shapes only a payload served from the cache; a computed one is returned as is.
|
|
25
|
+
*/
|
|
26
|
+
read(serveCached?: (payload: T) => T): Promise<T>;
|
|
27
|
+
/**
|
|
28
|
+
* Change the cached payload without a new snapshot, after any cold snapshot finishes. The cache
|
|
29
|
+
* keeps its age, so the fields it did not change keep their TTL and staleness ceiling. With no
|
|
30
|
+
* cached payload it computes one.
|
|
31
|
+
*/
|
|
32
|
+
patch(update: (payload: T) => T): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
export declare function createHealthCache<T>(options: {
|
|
35
|
+
snapshot: () => Promise<T>;
|
|
36
|
+
/** Called only when the serialized payload changed. */
|
|
37
|
+
publish: (payload: T) => void;
|
|
38
|
+
now?: () => number;
|
|
39
|
+
}): HealthCache<T>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side health cache (stale-while-revalidate). The snapshot reads Git and workspace state,
|
|
3
|
+
* and each Git read spawns a child process on the server loop. Paying that on the browser's FIRST
|
|
4
|
+
* `GET /api/health` is the few-seconds-blank the cockpit showed at load, so the live server computes
|
|
5
|
+
* the snapshot at its own pace: the GET and the WS `health` topic serve the cached value at once and
|
|
6
|
+
* revalidate behind the response, and the cache is pre-warmed at boot.
|
|
7
|
+
*/
|
|
8
|
+
/** How often a read starts a revalidation. */
|
|
9
|
+
export const HEALTH_TTL_MS = 5_000;
|
|
10
|
+
/**
|
|
11
|
+
* The staleness CEILING, a different job from the TTL. The TTL decides how often a revalidation
|
|
12
|
+
* starts; on its own it bounds nothing, because the revalidation is fire-and-forget. While a cockpit
|
|
13
|
+
* holds the `health` topic the publisher's interval keeps the cache warm — but the normal state of a
|
|
14
|
+
* background `hsq serve` is NO subscriber, and then nothing refreshes the cache at all: the next GET,
|
|
15
|
+
* an hour later, would answer with the boot pre-warm's payload. `repo.branch` going stale there is
|
|
16
|
+
* hearsay-tools/cezarion#369, so past this age the read waits for the compute.
|
|
17
|
+
*/
|
|
18
|
+
export const HEALTH_MAX_STALE_MS = 60_000;
|
|
19
|
+
export function createHealthCache(options) {
|
|
20
|
+
const now = options.now ?? Date.now;
|
|
21
|
+
let cache;
|
|
22
|
+
let inFlight;
|
|
23
|
+
const store = (payload, at) => {
|
|
24
|
+
const body = JSON.stringify(payload);
|
|
25
|
+
const changed = body !== cache?.body;
|
|
26
|
+
cache = { at, payload, body };
|
|
27
|
+
if (changed)
|
|
28
|
+
options.publish(payload);
|
|
29
|
+
};
|
|
30
|
+
const refresh = () => {
|
|
31
|
+
if (inFlight)
|
|
32
|
+
return inFlight;
|
|
33
|
+
inFlight = (async () => {
|
|
34
|
+
try {
|
|
35
|
+
const payload = await options.snapshot();
|
|
36
|
+
store(payload, now());
|
|
37
|
+
return payload;
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
inFlight = undefined;
|
|
41
|
+
}
|
|
42
|
+
})();
|
|
43
|
+
return inFlight;
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
refresh,
|
|
47
|
+
async read(serveCached = (payload) => payload) {
|
|
48
|
+
if (!cache)
|
|
49
|
+
return refresh();
|
|
50
|
+
const age = now() - cache.at;
|
|
51
|
+
if (age > HEALTH_MAX_STALE_MS)
|
|
52
|
+
return refresh();
|
|
53
|
+
if (age > HEALTH_TTL_MS)
|
|
54
|
+
void refresh().catch(() => { });
|
|
55
|
+
return serveCached(cache.payload);
|
|
56
|
+
},
|
|
57
|
+
async patch(update) {
|
|
58
|
+
await inFlight?.catch(() => { });
|
|
59
|
+
if (cache)
|
|
60
|
+
store(update(cache.payload), cache.at);
|
|
61
|
+
else
|
|
62
|
+
await refresh();
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=health-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-cache.js","sourceRoot":"","sources":["../../src/server/health-cache.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,8CAA8C;AAC9C,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC;AACnC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAkB1C,MAAM,UAAU,iBAAiB,CAAI,OAKpC;IACC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC;IACpC,IAAI,KAA2D,CAAC;IAChE,IAAI,QAAgC,CAAC;IACrC,MAAM,KAAK,GAAG,CAAC,OAAU,EAAE,EAAU,EAAQ,EAAE;QAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACrC,MAAM,OAAO,GAAG,IAAI,KAAK,KAAK,EAAE,IAAI,CAAC;QACrC,KAAK,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC9B,IAAI,OAAO;YAAE,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC,CAAC;IACF,MAAM,OAAO,GAAG,GAAe,EAAE;QAC/B,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAC9B,QAAQ,GAAG,CAAC,KAAK,IAAI,EAAE;YACrB,IAAI,CAAC;gBACH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC;gBACzC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;gBACtB,OAAO,OAAO,CAAC;YACjB,CAAC;oBAAS,CAAC;gBACT,QAAQ,GAAG,SAAS,CAAC;YACvB,CAAC;QACH,CAAC,CAAC,EAAE,CAAC;QACL,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;IACF,OAAO;QACL,OAAO;QACP,KAAK,CAAC,IAAI,CAAC,WAAW,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO;YAC3C,IAAI,CAAC,KAAK;gBAAE,OAAO,OAAO,EAAE,CAAC;YAC7B,MAAM,GAAG,GAAG,GAAG,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;YAC7B,IAAI,GAAG,GAAG,mBAAmB;gBAAE,OAAO,OAAO,EAAE,CAAC;YAChD,IAAI,GAAG,GAAG,aAAa;gBAAE,KAAK,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YACxD,OAAO,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACpC,CAAC;QACD,KAAK,CAAC,KAAK,CAAC,MAAM;YAChB,MAAM,QAAQ,EAAE,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YAChC,IAAI,KAAK;gBAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;;gBAC7C,MAAM,OAAO,EAAE,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/server/server.d.ts
CHANGED
|
@@ -3237,94 +3237,6 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
|
|
|
3237
3237
|
};
|
|
3238
3238
|
};
|
|
3239
3239
|
};
|
|
3240
|
-
}, "/"> | import("hono/types").MergeSchemaPath<{
|
|
3241
|
-
"/reports/state": {
|
|
3242
|
-
$get: {
|
|
3243
|
-
output: {
|
|
3244
|
-
error: string;
|
|
3245
|
-
};
|
|
3246
|
-
outputFormat: "json";
|
|
3247
|
-
status: 409;
|
|
3248
|
-
input: {};
|
|
3249
|
-
} | {
|
|
3250
|
-
output: {
|
|
3251
|
-
epoch: string;
|
|
3252
|
-
generation: number;
|
|
3253
|
-
metadataGeneration: number;
|
|
3254
|
-
};
|
|
3255
|
-
outputFormat: "json";
|
|
3256
|
-
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
3257
|
-
input: {};
|
|
3258
|
-
};
|
|
3259
|
-
};
|
|
3260
|
-
} & {
|
|
3261
|
-
"/reports": {
|
|
3262
|
-
$get: {
|
|
3263
|
-
output: {
|
|
3264
|
-
error: string;
|
|
3265
|
-
code?: "invalid_input" | undefined;
|
|
3266
|
-
};
|
|
3267
|
-
outputFormat: "json";
|
|
3268
|
-
status: 400;
|
|
3269
|
-
input: {
|
|
3270
|
-
query: {
|
|
3271
|
-
q?: string | undefined;
|
|
3272
|
-
before?: string | undefined;
|
|
3273
|
-
limit?: number | undefined;
|
|
3274
|
-
};
|
|
3275
|
-
};
|
|
3276
|
-
} | {
|
|
3277
|
-
output: {
|
|
3278
|
-
error: string;
|
|
3279
|
-
};
|
|
3280
|
-
outputFormat: "json";
|
|
3281
|
-
status: 400;
|
|
3282
|
-
input: {
|
|
3283
|
-
query: {
|
|
3284
|
-
q?: string | undefined;
|
|
3285
|
-
before?: string | undefined;
|
|
3286
|
-
limit?: number | undefined;
|
|
3287
|
-
};
|
|
3288
|
-
};
|
|
3289
|
-
} | {
|
|
3290
|
-
output: {
|
|
3291
|
-
error: string;
|
|
3292
|
-
};
|
|
3293
|
-
outputFormat: "json";
|
|
3294
|
-
status: 409;
|
|
3295
|
-
input: {
|
|
3296
|
-
query: {
|
|
3297
|
-
q?: string | undefined;
|
|
3298
|
-
before?: string | undefined;
|
|
3299
|
-
limit?: number | undefined;
|
|
3300
|
-
};
|
|
3301
|
-
};
|
|
3302
|
-
} | {
|
|
3303
|
-
output: {
|
|
3304
|
-
reports: {
|
|
3305
|
-
id: string;
|
|
3306
|
-
runId: string;
|
|
3307
|
-
name: string;
|
|
3308
|
-
title: string;
|
|
3309
|
-
createdAt: string;
|
|
3310
|
-
size: number;
|
|
3311
|
-
taskTitle: string;
|
|
3312
|
-
taskStatus: "cancelled" | "done" | "failed" | "queued" | "review" | "running" | "waiting";
|
|
3313
|
-
}[];
|
|
3314
|
-
nextCursor: string | null;
|
|
3315
|
-
total: number;
|
|
3316
|
-
};
|
|
3317
|
-
outputFormat: "json";
|
|
3318
|
-
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
3319
|
-
input: {
|
|
3320
|
-
query: {
|
|
3321
|
-
q?: string | undefined;
|
|
3322
|
-
before?: string | undefined;
|
|
3323
|
-
limit?: number | undefined;
|
|
3324
|
-
};
|
|
3325
|
-
};
|
|
3326
|
-
};
|
|
3327
|
-
};
|
|
3328
3240
|
}, "/"> | import("hono/types").MergeSchemaPath<{
|
|
3329
3241
|
"/ui-state": {
|
|
3330
3242
|
$get: {
|
|
@@ -3838,6 +3750,94 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
|
|
|
3838
3750
|
};
|
|
3839
3751
|
};
|
|
3840
3752
|
};
|
|
3753
|
+
}, "/"> | import("hono/types").MergeSchemaPath<{
|
|
3754
|
+
"/reports/state": {
|
|
3755
|
+
$get: {
|
|
3756
|
+
output: {
|
|
3757
|
+
error: string;
|
|
3758
|
+
};
|
|
3759
|
+
outputFormat: "json";
|
|
3760
|
+
status: 409;
|
|
3761
|
+
input: {};
|
|
3762
|
+
} | {
|
|
3763
|
+
output: {
|
|
3764
|
+
epoch: string;
|
|
3765
|
+
generation: number;
|
|
3766
|
+
metadataGeneration: number;
|
|
3767
|
+
};
|
|
3768
|
+
outputFormat: "json";
|
|
3769
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
3770
|
+
input: {};
|
|
3771
|
+
};
|
|
3772
|
+
};
|
|
3773
|
+
} & {
|
|
3774
|
+
"/reports": {
|
|
3775
|
+
$get: {
|
|
3776
|
+
output: {
|
|
3777
|
+
error: string;
|
|
3778
|
+
code?: "invalid_input" | undefined;
|
|
3779
|
+
};
|
|
3780
|
+
outputFormat: "json";
|
|
3781
|
+
status: 400;
|
|
3782
|
+
input: {
|
|
3783
|
+
query: {
|
|
3784
|
+
q?: string | undefined;
|
|
3785
|
+
before?: string | undefined;
|
|
3786
|
+
limit?: number | undefined;
|
|
3787
|
+
};
|
|
3788
|
+
};
|
|
3789
|
+
} | {
|
|
3790
|
+
output: {
|
|
3791
|
+
error: string;
|
|
3792
|
+
};
|
|
3793
|
+
outputFormat: "json";
|
|
3794
|
+
status: 400;
|
|
3795
|
+
input: {
|
|
3796
|
+
query: {
|
|
3797
|
+
q?: string | undefined;
|
|
3798
|
+
before?: string | undefined;
|
|
3799
|
+
limit?: number | undefined;
|
|
3800
|
+
};
|
|
3801
|
+
};
|
|
3802
|
+
} | {
|
|
3803
|
+
output: {
|
|
3804
|
+
error: string;
|
|
3805
|
+
};
|
|
3806
|
+
outputFormat: "json";
|
|
3807
|
+
status: 409;
|
|
3808
|
+
input: {
|
|
3809
|
+
query: {
|
|
3810
|
+
q?: string | undefined;
|
|
3811
|
+
before?: string | undefined;
|
|
3812
|
+
limit?: number | undefined;
|
|
3813
|
+
};
|
|
3814
|
+
};
|
|
3815
|
+
} | {
|
|
3816
|
+
output: {
|
|
3817
|
+
reports: {
|
|
3818
|
+
id: string;
|
|
3819
|
+
runId: string;
|
|
3820
|
+
name: string;
|
|
3821
|
+
title: string;
|
|
3822
|
+
createdAt: string;
|
|
3823
|
+
size: number;
|
|
3824
|
+
taskTitle: string;
|
|
3825
|
+
taskStatus: "cancelled" | "done" | "failed" | "queued" | "review" | "running" | "waiting";
|
|
3826
|
+
}[];
|
|
3827
|
+
nextCursor: string | null;
|
|
3828
|
+
total: number;
|
|
3829
|
+
};
|
|
3830
|
+
outputFormat: "json";
|
|
3831
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
3832
|
+
input: {
|
|
3833
|
+
query: {
|
|
3834
|
+
q?: string | undefined;
|
|
3835
|
+
before?: string | undefined;
|
|
3836
|
+
limit?: number | undefined;
|
|
3837
|
+
};
|
|
3838
|
+
};
|
|
3839
|
+
};
|
|
3840
|
+
};
|
|
3841
3841
|
}, "/"> | import("hono/types").MergeSchemaPath<{
|
|
3842
3842
|
"/skills": {
|
|
3843
3843
|
$get: {
|
|
@@ -18997,94 +18997,6 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
|
|
|
18997
18997
|
};
|
|
18998
18998
|
};
|
|
18999
18999
|
};
|
|
19000
|
-
}, "/"> | import("hono/types").MergeSchemaPath<{
|
|
19001
|
-
"/reports/state": {
|
|
19002
|
-
$get: {
|
|
19003
|
-
output: {
|
|
19004
|
-
error: string;
|
|
19005
|
-
};
|
|
19006
|
-
outputFormat: "json";
|
|
19007
|
-
status: 409;
|
|
19008
|
-
input: {};
|
|
19009
|
-
} | {
|
|
19010
|
-
output: {
|
|
19011
|
-
epoch: string;
|
|
19012
|
-
generation: number;
|
|
19013
|
-
metadataGeneration: number;
|
|
19014
|
-
};
|
|
19015
|
-
outputFormat: "json";
|
|
19016
|
-
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
19017
|
-
input: {};
|
|
19018
|
-
};
|
|
19019
|
-
};
|
|
19020
|
-
} & {
|
|
19021
|
-
"/reports": {
|
|
19022
|
-
$get: {
|
|
19023
|
-
output: {
|
|
19024
|
-
error: string;
|
|
19025
|
-
code?: "invalid_input" | undefined;
|
|
19026
|
-
};
|
|
19027
|
-
outputFormat: "json";
|
|
19028
|
-
status: 400;
|
|
19029
|
-
input: {
|
|
19030
|
-
query: {
|
|
19031
|
-
q?: string | undefined;
|
|
19032
|
-
before?: string | undefined;
|
|
19033
|
-
limit?: number | undefined;
|
|
19034
|
-
};
|
|
19035
|
-
};
|
|
19036
|
-
} | {
|
|
19037
|
-
output: {
|
|
19038
|
-
error: string;
|
|
19039
|
-
};
|
|
19040
|
-
outputFormat: "json";
|
|
19041
|
-
status: 400;
|
|
19042
|
-
input: {
|
|
19043
|
-
query: {
|
|
19044
|
-
q?: string | undefined;
|
|
19045
|
-
before?: string | undefined;
|
|
19046
|
-
limit?: number | undefined;
|
|
19047
|
-
};
|
|
19048
|
-
};
|
|
19049
|
-
} | {
|
|
19050
|
-
output: {
|
|
19051
|
-
error: string;
|
|
19052
|
-
};
|
|
19053
|
-
outputFormat: "json";
|
|
19054
|
-
status: 409;
|
|
19055
|
-
input: {
|
|
19056
|
-
query: {
|
|
19057
|
-
q?: string | undefined;
|
|
19058
|
-
before?: string | undefined;
|
|
19059
|
-
limit?: number | undefined;
|
|
19060
|
-
};
|
|
19061
|
-
};
|
|
19062
|
-
} | {
|
|
19063
|
-
output: {
|
|
19064
|
-
reports: {
|
|
19065
|
-
id: string;
|
|
19066
|
-
runId: string;
|
|
19067
|
-
name: string;
|
|
19068
|
-
title: string;
|
|
19069
|
-
createdAt: string;
|
|
19070
|
-
size: number;
|
|
19071
|
-
taskTitle: string;
|
|
19072
|
-
taskStatus: "cancelled" | "done" | "failed" | "queued" | "review" | "running" | "waiting";
|
|
19073
|
-
}[];
|
|
19074
|
-
nextCursor: string | null;
|
|
19075
|
-
total: number;
|
|
19076
|
-
};
|
|
19077
|
-
outputFormat: "json";
|
|
19078
|
-
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
19079
|
-
input: {
|
|
19080
|
-
query: {
|
|
19081
|
-
q?: string | undefined;
|
|
19082
|
-
before?: string | undefined;
|
|
19083
|
-
limit?: number | undefined;
|
|
19084
|
-
};
|
|
19085
|
-
};
|
|
19086
|
-
};
|
|
19087
|
-
};
|
|
19088
19000
|
}, "/"> | import("hono/types").MergeSchemaPath<{
|
|
19089
19001
|
"/ui-state": {
|
|
19090
19002
|
$get: {
|
|
@@ -19598,6 +19510,94 @@ export declare function createApp(deps: ServerDeps): import("hono/hono-base").Ho
|
|
|
19598
19510
|
};
|
|
19599
19511
|
};
|
|
19600
19512
|
};
|
|
19513
|
+
}, "/"> | import("hono/types").MergeSchemaPath<{
|
|
19514
|
+
"/reports/state": {
|
|
19515
|
+
$get: {
|
|
19516
|
+
output: {
|
|
19517
|
+
error: string;
|
|
19518
|
+
};
|
|
19519
|
+
outputFormat: "json";
|
|
19520
|
+
status: 409;
|
|
19521
|
+
input: {};
|
|
19522
|
+
} | {
|
|
19523
|
+
output: {
|
|
19524
|
+
epoch: string;
|
|
19525
|
+
generation: number;
|
|
19526
|
+
metadataGeneration: number;
|
|
19527
|
+
};
|
|
19528
|
+
outputFormat: "json";
|
|
19529
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
19530
|
+
input: {};
|
|
19531
|
+
};
|
|
19532
|
+
};
|
|
19533
|
+
} & {
|
|
19534
|
+
"/reports": {
|
|
19535
|
+
$get: {
|
|
19536
|
+
output: {
|
|
19537
|
+
error: string;
|
|
19538
|
+
code?: "invalid_input" | undefined;
|
|
19539
|
+
};
|
|
19540
|
+
outputFormat: "json";
|
|
19541
|
+
status: 400;
|
|
19542
|
+
input: {
|
|
19543
|
+
query: {
|
|
19544
|
+
q?: string | undefined;
|
|
19545
|
+
before?: string | undefined;
|
|
19546
|
+
limit?: number | undefined;
|
|
19547
|
+
};
|
|
19548
|
+
};
|
|
19549
|
+
} | {
|
|
19550
|
+
output: {
|
|
19551
|
+
error: string;
|
|
19552
|
+
};
|
|
19553
|
+
outputFormat: "json";
|
|
19554
|
+
status: 400;
|
|
19555
|
+
input: {
|
|
19556
|
+
query: {
|
|
19557
|
+
q?: string | undefined;
|
|
19558
|
+
before?: string | undefined;
|
|
19559
|
+
limit?: number | undefined;
|
|
19560
|
+
};
|
|
19561
|
+
};
|
|
19562
|
+
} | {
|
|
19563
|
+
output: {
|
|
19564
|
+
error: string;
|
|
19565
|
+
};
|
|
19566
|
+
outputFormat: "json";
|
|
19567
|
+
status: 409;
|
|
19568
|
+
input: {
|
|
19569
|
+
query: {
|
|
19570
|
+
q?: string | undefined;
|
|
19571
|
+
before?: string | undefined;
|
|
19572
|
+
limit?: number | undefined;
|
|
19573
|
+
};
|
|
19574
|
+
};
|
|
19575
|
+
} | {
|
|
19576
|
+
output: {
|
|
19577
|
+
reports: {
|
|
19578
|
+
id: string;
|
|
19579
|
+
runId: string;
|
|
19580
|
+
name: string;
|
|
19581
|
+
title: string;
|
|
19582
|
+
createdAt: string;
|
|
19583
|
+
size: number;
|
|
19584
|
+
taskTitle: string;
|
|
19585
|
+
taskStatus: "cancelled" | "done" | "failed" | "queued" | "review" | "running" | "waiting";
|
|
19586
|
+
}[];
|
|
19587
|
+
nextCursor: string | null;
|
|
19588
|
+
total: number;
|
|
19589
|
+
};
|
|
19590
|
+
outputFormat: "json";
|
|
19591
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
19592
|
+
input: {
|
|
19593
|
+
query: {
|
|
19594
|
+
q?: string | undefined;
|
|
19595
|
+
before?: string | undefined;
|
|
19596
|
+
limit?: number | undefined;
|
|
19597
|
+
};
|
|
19598
|
+
};
|
|
19599
|
+
};
|
|
19600
|
+
};
|
|
19601
19601
|
}, "/"> | import("hono/types").MergeSchemaPath<{
|
|
19602
19602
|
"/skills": {
|
|
19603
19603
|
$get: {
|
package/dist/server/server.js
CHANGED
|
@@ -110,6 +110,7 @@ import { worktreeDiff, worktreeSizeBytes } from '../git-worktree.js';
|
|
|
110
110
|
import { releaseThenRemoveWorktree } from '../git-worktree-release.js';
|
|
111
111
|
import { isReclaimable, reclaimWorktree, reclaimWorktrees, selectReclaimableWorktrees } from '../runs/retention.js';
|
|
112
112
|
import { getBranches, getCommit, getDiff, getLogWithParents, getRepoInfo, getStatus, getTracking } from './git.js';
|
|
113
|
+
import { createHealthCache, HEALTH_TTL_MS } from './health-cache.js';
|
|
113
114
|
import { createGithubBranchForge } from './repo-branch-forge.js';
|
|
114
115
|
import { attributeLog, classifyInputFor, deleteBranches, forgetRepoBranches, readRepoBranchCounts, readRepoBranches } from './repo-branches.js';
|
|
115
116
|
import { claimRepoGitMutation, localPullBranches, pullRepoCheckout } from './repo-pull.js';
|
|
@@ -678,11 +679,9 @@ export function createApp(deps) {
|
|
|
678
679
|
.then((changed) => {
|
|
679
680
|
if (!changed)
|
|
680
681
|
return;
|
|
681
|
-
// Probe is settled;
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
await refreshHealth();
|
|
685
|
-
})().catch(() => { });
|
|
682
|
+
// Probe is settled; publish the new checks to both transports. Only availability changed:
|
|
683
|
+
// re-reading Git would spawn processes on this loop (hearsay-tools/squawk#3355).
|
|
684
|
+
void healthCache.patch((payload) => ({ ...payload, checks: backendChecks })).catch(() => { });
|
|
686
685
|
});
|
|
687
686
|
}
|
|
688
687
|
return backendChecks;
|
|
@@ -730,69 +729,24 @@ export function createApp(deps) {
|
|
|
730
729
|
bootProject: workspace.bootProject,
|
|
731
730
|
};
|
|
732
731
|
};
|
|
733
|
-
//
|
|
734
|
-
//
|
|
735
|
-
// probes have their own nonblocking cache above. Paying that on the browser's FIRST `GET /api/health` is
|
|
736
|
-
// exactly the few-seconds-blank the cockpit showed at load. So on the live
|
|
737
|
-
// server the snapshot is computed at the server's OWN pace: both the GET and
|
|
738
|
-
// the WS `health` topic serve the cached value immediately and revalidate
|
|
739
|
-
// behind the response, and the cache is pre-warmed at boot so that first
|
|
740
|
-
// request lands on a warm value instead of the cold compute.
|
|
741
|
-
const HEALTH_TTL_MS = 5_000;
|
|
742
|
-
// The staleness CEILING, which is a different job from the TTL above. The TTL
|
|
743
|
-
// decides how often a revalidation is kicked off; on its own it bounds nothing,
|
|
744
|
-
// because the revalidation is fire-and-forget. While a cockpit holds the
|
|
745
|
-
// `health` topic the publisher's interval keeps the cache warm and the two are
|
|
746
|
-
// the same number — but the normal state of a background `hsq serve` is NO
|
|
747
|
-
// subscriber, and then nothing refreshes the cache at all: the next `GET
|
|
748
|
-
// /api/health`, an hour later, would answer with the boot pre-warm's payload
|
|
749
|
-
// and only the request AFTER it would see the truth. `repo.branch` going stale there is
|
|
750
|
-
// literally #369, so past this age correctness beats the latency win and the
|
|
751
|
-
// read waits for the compute. `refreshHealth` dedupes, so waiting costs one.
|
|
752
|
-
const HEALTH_MAX_STALE_MS = 60_000;
|
|
753
|
-
let healthCache;
|
|
754
|
-
let healthInFlight;
|
|
755
|
-
// Set while the topic has a subscriber; a change a refresh detects is pushed
|
|
756
|
-
// here (a noop when nobody is listening).
|
|
732
|
+
// Stale-while-revalidate cache over the snapshot; see health-cache.ts.
|
|
733
|
+
// Set while the topic has a subscriber (a noop when nobody is listening).
|
|
757
734
|
let publishHealth = () => { };
|
|
758
|
-
const
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
const body = JSON.stringify(payload);
|
|
767
|
-
const changed = body !== healthCache?.body;
|
|
768
|
-
healthCache = { at: Date.now(), payload, body };
|
|
769
|
-
if (changed) {
|
|
770
|
-
publishHealth(payload);
|
|
771
|
-
workspaceEvents.emit('health', payload);
|
|
772
|
-
} // only a real change reaches either transport
|
|
773
|
-
return payload;
|
|
774
|
-
}
|
|
775
|
-
finally {
|
|
776
|
-
healthInFlight = undefined;
|
|
777
|
-
}
|
|
778
|
-
})();
|
|
779
|
-
return healthInFlight;
|
|
780
|
-
};
|
|
735
|
+
const healthCache = createHealthCache({
|
|
736
|
+
snapshot: healthSnapshot,
|
|
737
|
+
publish: (payload) => {
|
|
738
|
+
publishHealth(payload);
|
|
739
|
+
workspaceEvents.emit('health', payload);
|
|
740
|
+
},
|
|
741
|
+
});
|
|
742
|
+
const refreshHealth = () => healthCache.refresh();
|
|
781
743
|
// The read the GET and the topic snapshot share. On the live server (a hub is
|
|
782
|
-
// injected) it answers from cache
|
|
783
|
-
//
|
|
784
|
-
// keeping a cache coherent, so it computes fresh, exactly as before.
|
|
744
|
+
// injected) it answers from cache; without a hub — a bare app in tests — there is
|
|
745
|
+
// no refresher keeping a cache coherent, so it computes fresh, exactly as before.
|
|
785
746
|
const readHealth = async () => {
|
|
786
747
|
if (!deps.socketHub)
|
|
787
748
|
return healthSnapshot();
|
|
788
|
-
|
|
789
|
-
return refreshHealth(); // first ever: nothing to serve yet
|
|
790
|
-
const age = Date.now() - healthCache.at;
|
|
791
|
-
if (age > HEALTH_MAX_STALE_MS)
|
|
792
|
-
return refreshHealth(); // too old to serve — wait for the truth
|
|
793
|
-
if (age > HEALTH_TTL_MS)
|
|
794
|
-
void refreshHealth(); // stale: refresh, don't wait on it
|
|
795
|
-
return { ...healthCache.payload, capabilities: capabilities() }; // per request, like the gates (ADR 0055)
|
|
749
|
+
return healthCache.read((payload) => ({ ...payload, capabilities: capabilities() })); // per request, like the gates (ADR 0055)
|
|
796
750
|
};
|
|
797
751
|
// ---- chained family: health (workspace-level) ----------------------------
|
|
798
752
|
// Written as ONE chained expression rather than a loose `app.get(...)`
|