opencode-harness-kit 0.5.3 → 0.5.5
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 +207 -17
- package/bin/oc-harness.mjs +278 -45
- package/dist/config.d.ts +5 -0
- package/dist/denylist.d.ts +5 -1
- package/dist/guard.d.ts +17 -1
- package/dist/health.d.ts +69 -7
- package/dist/index.js +452 -68
- package/dist/profile.d.ts +32 -2
- package/dist/telemetry-store.d.ts +22 -0
- package/docs/EXIT-CODES.md +7 -0
- package/docs/KNOWN-LIMITS.md +18 -7
- package/eval/measure-prune.mjs +13 -4
- package/package.json +1 -1
- package/src/config.js +126 -3
- package/src/denylist.js +46 -2
- package/src/guard.ts +78 -7
- package/src/health.js +130 -5
- package/src/lane-usage.js +13 -6
- package/src/profile.js +187 -25
- package/src/prune.ts +58 -13
- package/src/router.ts +217 -17
- package/src/rules.js +329 -19
- package/src/sqlite.js +80 -0
- package/src/tasks.js +193 -40
- package/src/telemetry-store.ts +27 -4
- package/src/trust.js +182 -54
package/dist/health.d.ts
CHANGED
|
@@ -1,30 +1,88 @@
|
|
|
1
|
+
export type SpentEntry = {
|
|
2
|
+
/**
|
|
3
|
+
* when the route was recorded as spent
|
|
4
|
+
*/
|
|
5
|
+
at: string;
|
|
6
|
+
/**
|
|
7
|
+
* the pattern that matched
|
|
8
|
+
*/
|
|
9
|
+
reason: string;
|
|
10
|
+
};
|
|
1
11
|
export type Health = {
|
|
2
|
-
unhealthy: Record<string,
|
|
3
|
-
at: string;
|
|
4
|
-
reason: string;
|
|
5
|
-
}>;
|
|
12
|
+
unhealthy: Record<string, SpentEntry>;
|
|
6
13
|
active?: string;
|
|
7
14
|
};
|
|
8
15
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
16
|
+
* The window, in milliseconds, a recorded spent route is honoured for.
|
|
17
|
+
*
|
|
18
|
+
* Read at call time rather than at import time, so a caller that changes it
|
|
19
|
+
* does not have to reload the module to see the effect.
|
|
20
|
+
*
|
|
21
|
+
* @returns {number}
|
|
12
22
|
*/
|
|
23
|
+
export declare function spentWindowMs(): number;
|
|
24
|
+
/**
|
|
25
|
+
* Whether a recorded route is still spent.
|
|
26
|
+
*
|
|
27
|
+
* An entry with no usable timestamp is KEPT. The router always stamps one,
|
|
28
|
+
* so an entry without one was written by a hand, and honouring a standing
|
|
29
|
+
* statement is safer than putting a route that may be dead back into a
|
|
30
|
+
* fleet. An entry that cannot be shown to be stale is not dropped.
|
|
31
|
+
*
|
|
32
|
+
* @param {unknown} entry
|
|
33
|
+
* @param {number} [now]
|
|
34
|
+
* @returns {boolean}
|
|
35
|
+
*/
|
|
36
|
+
export declare function isSpent(entry: unknown, now?: number): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The spent routes that are still spent.
|
|
39
|
+
*
|
|
40
|
+
* Every reader of the file goes through here, so the router and the effort
|
|
41
|
+
* hook cannot disagree about which routes are down. A reader that looked at
|
|
42
|
+
* the raw file would see a route that came back an hour ago as spent, and
|
|
43
|
+
* would fail the fleet over onto a model that works.
|
|
44
|
+
*
|
|
45
|
+
* @param {Health} health
|
|
46
|
+
* @param {number} [now]
|
|
47
|
+
* @returns {Record<string, SpentEntry>}
|
|
48
|
+
*/
|
|
49
|
+
export declare function liveUnhealthy(health: Health, now?: number): Record<string, SpentEntry>;
|
|
13
50
|
/**
|
|
14
51
|
* @param {string} dir the project root
|
|
15
52
|
* @returns {string}
|
|
16
53
|
*/
|
|
17
54
|
export declare function healthPath(dir: string): string;
|
|
18
55
|
/**
|
|
56
|
+
* The health file, or an empty one.
|
|
57
|
+
*
|
|
58
|
+
* A file that is not an object - null, an array, a number, a string - is not
|
|
59
|
+
* a health file, and reading it as one made `unhealthyModels` throw on a
|
|
60
|
+
* null. That call sits inside a bare catch in src/index.ts, so the throw
|
|
61
|
+
* silently skipped the effort plan AND the write of `.space/active` that the
|
|
62
|
+
* pruner depends on: a corrupt file switched the pruner off without a word.
|
|
63
|
+
*
|
|
19
64
|
* @param {string} dir the project root
|
|
20
65
|
* @returns {Health}
|
|
21
66
|
*/
|
|
22
67
|
export declare function readHealth(dir: string): Health;
|
|
23
68
|
/**
|
|
69
|
+
* Write the health file, without the routes whose window has passed.
|
|
70
|
+
*
|
|
71
|
+
* The expiry is applied on the way out as well as on the way in, so a file
|
|
72
|
+
* that is read and written again - which the router does on every event -
|
|
73
|
+
* does not carry its dead routes forever.
|
|
74
|
+
*
|
|
24
75
|
* @param {string} dir the project root
|
|
25
76
|
* @param {Health} health
|
|
26
77
|
*/
|
|
27
78
|
export declare function writeHealth(dir: string, health: Health): void;
|
|
79
|
+
/**
|
|
80
|
+
* The routes on disk that are still spent.
|
|
81
|
+
*
|
|
82
|
+
* @param {string} dir the project root
|
|
83
|
+
* @returns {Record<string, SpentEntry>}
|
|
84
|
+
*/
|
|
85
|
+
export declare function unhealthyRoutes(dir: string): Record<string, SpentEntry>;
|
|
28
86
|
/**
|
|
29
87
|
* The models a previous session found spent.
|
|
30
88
|
*
|
|
@@ -37,6 +95,10 @@ export declare function writeHealth(dir: string, health: Health): void;
|
|
|
37
95
|
* lane chains list bare model ids, so the prefix is dropped here. Comparing
|
|
38
96
|
* the two directly would never match, and a spent route would look healthy.
|
|
39
97
|
*
|
|
98
|
+
* A route whose window has passed is not spent any more, and is not returned
|
|
99
|
+
* here: the provider's quota comes back at 00:00 UTC, and a lane that stays
|
|
100
|
+
* on its fallback forever is a lane that never comes back either.
|
|
101
|
+
*
|
|
40
102
|
* @param {string} dir the project root
|
|
41
103
|
* @returns {Set<string>}
|
|
42
104
|
*/
|