@indigoai-us/hq-cli 5.345.252 → 5.345.254
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 +73 -0
- package/contracts/host-canary-release.json +11 -5
- package/dist/command-catalog.generated.d.ts +209 -0
- package/dist/command-catalog.generated.js +257 -0
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -0
- package/dist/commands/ci-intake.d.ts +32 -0
- package/dist/commands/ci-intake.js +294 -0
- package/dist/commands/ci-metrics.d.ts +8 -0
- package/dist/commands/ci-metrics.js +55 -0
- package/dist/commands/ci-priorities.d.ts +56 -0
- package/dist/commands/ci-priorities.js +144 -0
- package/dist/commands/ci.d.ts +13 -0
- package/dist/commands/ci.js +11 -0
- package/dist/commands/cloud.d.ts +11 -0
- package/dist/commands/cloud.js +76 -0
- package/dist/commands/files.d.ts +62 -0
- package/dist/commands/files.js +249 -8
- package/dist/lib/bot/fleet-cron.d.ts +15 -0
- package/dist/lib/bot/fleet-cron.js +119 -20
- package/dist/lib/daemon/run.js +4 -3
- package/dist/lib/daemon/verified-jq.d.ts +6 -0
- package/dist/lib/daemon/verified-jq.js +17 -5
- package/dist/lib/delivery/migrations.d.ts +32 -1
- package/dist/lib/delivery/migrations.js +69 -8
- package/dist/lib/hook-engine/adapter-core-pin.d.ts +2 -1
- package/dist/lib/hook-engine/adapter-core-pin.js +2 -1
- package/dist/lib/hook-engine/coverage.d.ts +15 -0
- package/dist/lib/hook-engine/coverage.js +62 -1
- package/dist/lib/hook-engine/fleet-registration.d.ts +4 -0
- package/dist/lib/hook-engine/fleet-registration.js +25 -3
- package/dist/lib/smart-ci/cost.d.ts +72 -0
- package/dist/lib/smart-ci/cost.js +120 -0
- package/dist/lib/smart-ci/github.d.ts +112 -0
- package/dist/lib/smart-ci/github.js +267 -0
- package/dist/lib/smart-ci/intake.d.ts +288 -0
- package/dist/lib/smart-ci/intake.js +1078 -0
- package/dist/lib/smart-ci/ledger.d.ts +218 -0
- package/dist/lib/smart-ci/ledger.js +527 -0
- package/dist/lib/smart-ci/metrics.d.ts +137 -0
- package/dist/lib/smart-ci/metrics.js +249 -0
- package/dist/lib/smart-ci/priorities.d.ts +331 -0
- package/dist/lib/smart-ci/priorities.js +964 -0
- package/dist/lib/smart-ci/priority-refresh.d.ts +192 -0
- package/dist/lib/smart-ci/priority-refresh.js +366 -0
- package/dist/lib/smart-ci/priority-snapshots.d.ts +88 -0
- package/dist/lib/smart-ci/priority-snapshots.js +233 -0
- package/dist/lib/smart-ci/records.d.ts +265 -0
- package/dist/lib/smart-ci/records.js +281 -0
- package/dist/lib/smart-ci/reducer.d.ts +67 -0
- package/dist/lib/smart-ci/reducer.js +261 -0
- package/dist/lib/smart-ci/sources.d.ts +294 -0
- package/dist/lib/smart-ci/sources.js +659 -0
- package/dist/lib/smart-ci/text.d.ts +24 -0
- package/dist/lib/smart-ci/text.js +83 -0
- package/dist/lib/smart-ci/work-in-flight.d.ts +68 -0
- package/dist/lib/smart-ci/work-in-flight.js +154 -0
- package/dist/lib/sync/cli-manifest-reconcile.d.ts +20 -0
- package/dist/lib/sync/cli-manifest-reconcile.js +170 -0
- package/dist/lib/sync-core/engine-holds.d.ts +14 -0
- package/dist/lib/sync-core/engine-holds.js +78 -11
- package/dist/lib/sync-core/hand-back.d.ts +1 -0
- package/dist/lib/sync-core/hand-back.js +7 -2
- package/dist/lib/sync-core/reconcile.js +10 -2
- package/dist/utils/host-registration.d.ts +1 -0
- package/dist/utils/host-registration.js +1 -1
- package/package.json +9 -7
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { type SmartCiNamespace, type StoredSmartCiRecord } from "../delivery/migrations.js";
|
|
2
|
+
import { type CommitStep, type OpenReport } from "../delivery/store.js";
|
|
3
|
+
export interface Upsert {
|
|
4
|
+
kind: string;
|
|
5
|
+
id: string;
|
|
6
|
+
body: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
export interface CursorMove {
|
|
9
|
+
stream: string;
|
|
10
|
+
position: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ApplyReport {
|
|
13
|
+
/** Records that did not exist before this commit. */
|
|
14
|
+
created: number;
|
|
15
|
+
/** Records whose body changed. */
|
|
16
|
+
updated: number;
|
|
17
|
+
/** Upserts that matched the stored body exactly and wrote nothing. */
|
|
18
|
+
unchanged: number;
|
|
19
|
+
cursorsMoved: number;
|
|
20
|
+
/** False when nothing differed and no commit was made. */
|
|
21
|
+
committed: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** One record with the times the ledger wrote it. */
|
|
24
|
+
export interface LedgerRecord<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
25
|
+
kind: string;
|
|
26
|
+
id: string;
|
|
27
|
+
recordedAt: string;
|
|
28
|
+
updatedAt: string;
|
|
29
|
+
body: T;
|
|
30
|
+
}
|
|
31
|
+
export interface LedgerOpenOptions {
|
|
32
|
+
dir: string;
|
|
33
|
+
controllerId: string;
|
|
34
|
+
clock?: () => number;
|
|
35
|
+
host?: string;
|
|
36
|
+
pid?: number;
|
|
37
|
+
isPidAlive?: (pid: number) => boolean;
|
|
38
|
+
/** Test hook, passed to the store: throwing simulates a crash at that commit step. */
|
|
39
|
+
crashPoint?: (step: CommitStep) => void;
|
|
40
|
+
}
|
|
41
|
+
export type SmartCiLedgerErrorCode = "STORE_HAS_WORKERS" | "SCOPE_INVALID" | "BLOB_MISSING" | "BLOB_CORRUPT";
|
|
42
|
+
export declare class SmartCiLedgerError extends Error {
|
|
43
|
+
readonly code: SmartCiLedgerErrorCode;
|
|
44
|
+
constructor(code: SmartCiLedgerErrorCode, message: string);
|
|
45
|
+
}
|
|
46
|
+
/** Where the ledger lives when no directory is given: HQ_SMART_CI_STORE_DIR, else ~/.hq/delivery/ledger. */
|
|
47
|
+
export declare function defaultLedgerDir(env?: NodeJS.ProcessEnv, home?: string): string;
|
|
48
|
+
export interface ScopeRef {
|
|
49
|
+
/** Company slug. Required: there is no default company. */
|
|
50
|
+
company: string;
|
|
51
|
+
/** The module's own name, for example "priorities". */
|
|
52
|
+
namespace: string;
|
|
53
|
+
}
|
|
54
|
+
/** The field of a record body that names its blob. */
|
|
55
|
+
export declare const BLOB_FIELD = "$blob";
|
|
56
|
+
export interface BlobRef {
|
|
57
|
+
sha256: string;
|
|
58
|
+
bytes: number;
|
|
59
|
+
}
|
|
60
|
+
/** Read a blob by its hash and check the bytes against it. */
|
|
61
|
+
export declare function readBlob(dir: string, company: string, sha256: string): Buffer;
|
|
62
|
+
/** A read-only view of the namespace, with lookup by kind and id. */
|
|
63
|
+
export declare class SmartCiView {
|
|
64
|
+
/** The ledger directory, when the view was read from one: needed to read blobs. */
|
|
65
|
+
readonly dir: string | null;
|
|
66
|
+
private readonly byKey;
|
|
67
|
+
private readonly byKind;
|
|
68
|
+
private readonly cursorMap;
|
|
69
|
+
constructor(ns: SmartCiNamespace,
|
|
70
|
+
/** The ledger directory, when the view was read from one: needed to read blobs. */
|
|
71
|
+
dir?: string | null);
|
|
72
|
+
get<T extends Record<string, unknown>>(kind: string, id: string): T | undefined;
|
|
73
|
+
list<T extends Record<string, unknown>>(kind: string): T[];
|
|
74
|
+
records<T extends Record<string, unknown>>(kind: string): LedgerRecord<T>[];
|
|
75
|
+
latest<T extends Record<string, unknown>>(kind: string): LedgerRecord<T> | undefined;
|
|
76
|
+
count(kind: string): number;
|
|
77
|
+
cursor(stream: string): string | null;
|
|
78
|
+
/** The records of one module for one company, read-only. */
|
|
79
|
+
scope(ref: ScopeRef): ScopedView;
|
|
80
|
+
}
|
|
81
|
+
/** Reads of one scope. Works on a snapshot, so it needs no ownership. */
|
|
82
|
+
export declare class ScopedView {
|
|
83
|
+
private readonly view;
|
|
84
|
+
private readonly prefix;
|
|
85
|
+
private readonly company;
|
|
86
|
+
constructor(view: Pick<SmartCiView, "get" | "list" | "records" | "latest" | "dir">, prefix: string, company: string);
|
|
87
|
+
get<T extends Record<string, unknown>>(kind: string, id: string): T | undefined;
|
|
88
|
+
list<T extends Record<string, unknown>>(kind: string): T[];
|
|
89
|
+
records<T extends Record<string, unknown>>(kind: string): LedgerRecord<T>[];
|
|
90
|
+
/** The record of this kind written last, or undefined when there is none. */
|
|
91
|
+
latest<T extends Record<string, unknown>>(kind: string): LedgerRecord<T> | undefined;
|
|
92
|
+
/** The blob stored with a record, or null when the record has none. */
|
|
93
|
+
blob(kind: string, id: string): Buffer | null;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Read the committed smart-ci namespace of the active file without taking
|
|
97
|
+
* ownership, so a read works while the intake holds the store. Returns an
|
|
98
|
+
* empty namespace when the directory holds no store yet.
|
|
99
|
+
*/
|
|
100
|
+
export declare function readSmartCiSnapshot(dir: string, waitMs?: number): SmartCiNamespace;
|
|
101
|
+
/** The archive directories of a ledger, oldest first. */
|
|
102
|
+
export declare function listArchives(dir: string): string[];
|
|
103
|
+
export interface HistoryOptions {
|
|
104
|
+
/** Leave out archives whose records were all last written before this time (ISO). Default: read every archive. */
|
|
105
|
+
since?: string;
|
|
106
|
+
/** Keep only the records this accepts, to bound memory on a long window. */
|
|
107
|
+
keep?: (record: StoredSmartCiRecord) => boolean;
|
|
108
|
+
waitMs?: number;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The active file and the archives as one namespace, each record once. Where
|
|
112
|
+
* a key is in more than one file (a kill between writing an archive and
|
|
113
|
+
* removing the record from the active file, or a record written again after
|
|
114
|
+
* it was archived) the active file wins, then the newest archive.
|
|
115
|
+
*/
|
|
116
|
+
export declare function readSmartCiHistory(dir: string, opts?: HistoryOptions): SmartCiNamespace;
|
|
117
|
+
export interface RotateOptions {
|
|
118
|
+
/** Only records of these kinds are considered. */
|
|
119
|
+
kinds: readonly string[];
|
|
120
|
+
/** Move records last written before this time (ISO). */
|
|
121
|
+
olderThan: string;
|
|
122
|
+
/** Records this returns true for stay in the active file whatever their age. */
|
|
123
|
+
keep?: (record: LedgerRecord) => boolean;
|
|
124
|
+
}
|
|
125
|
+
export interface RotateReport {
|
|
126
|
+
moved: number;
|
|
127
|
+
/** Archive directories written, by name. */
|
|
128
|
+
archives: string[];
|
|
129
|
+
}
|
|
130
|
+
export interface PruneOptions {
|
|
131
|
+
/** Keep this many of the most recently written records of the kind. */
|
|
132
|
+
keepLatest?: number;
|
|
133
|
+
/** Remove records last written before this time (ISO). */
|
|
134
|
+
olderThan?: string;
|
|
135
|
+
}
|
|
136
|
+
/** The single writer of the smart-ci namespace. One process holds it at a time; a second open is refused by the store. */
|
|
137
|
+
export declare class SmartCiLedger {
|
|
138
|
+
readonly dir: string;
|
|
139
|
+
readonly report: OpenReport;
|
|
140
|
+
private readonly store;
|
|
141
|
+
private readonly openOptions;
|
|
142
|
+
/** Position of each record in state.smartCi.records. */
|
|
143
|
+
private readonly index;
|
|
144
|
+
private readonly cursorIndex;
|
|
145
|
+
private constructor();
|
|
146
|
+
private reindex;
|
|
147
|
+
/**
|
|
148
|
+
* Take ownership of the store directory. A live owner is refused; a dead
|
|
149
|
+
* owner on this host is taken over. A store that has delivery workers
|
|
150
|
+
* enrolled is a delivery controller's store, not a Smart CI ledger: it is
|
|
151
|
+
* refused before anything is written to the directory.
|
|
152
|
+
*/
|
|
153
|
+
static open(opts: LedgerOpenOptions): SmartCiLedger;
|
|
154
|
+
get<T extends Record<string, unknown>>(kind: string, id: string): T | undefined;
|
|
155
|
+
list<T extends Record<string, unknown>>(kind: string): T[];
|
|
156
|
+
records<T extends Record<string, unknown>>(kind: string): LedgerRecord<T>[];
|
|
157
|
+
/** The record of this kind written last, or undefined when there is none. */
|
|
158
|
+
latest<T extends Record<string, unknown>>(kind: string): LedgerRecord<T> | undefined;
|
|
159
|
+
/** Every record, of every kind. */
|
|
160
|
+
allRecords(): LedgerRecord[];
|
|
161
|
+
count(kind?: string): number;
|
|
162
|
+
cursor(stream: string): string | null;
|
|
163
|
+
/**
|
|
164
|
+
* Write records and move cursors in one atomic commit. An upsert whose body
|
|
165
|
+
* equals the stored one writes nothing; when nothing differs at all there is
|
|
166
|
+
* no commit. Either everything in the call is on disk afterwards or nothing is.
|
|
167
|
+
*/
|
|
168
|
+
apply(upserts: readonly Upsert[], cursors?: readonly CursorMove[]): ApplyReport;
|
|
169
|
+
/** Remove records by key in one commit. Returns how many were there. */
|
|
170
|
+
remove(keys: ReadonlyArray<{
|
|
171
|
+
kind: string;
|
|
172
|
+
id: string;
|
|
173
|
+
}>): number;
|
|
174
|
+
/**
|
|
175
|
+
* Remove old records of one kind in one commit: all but the `keepLatest`
|
|
176
|
+
* most recently written, or those last written before `olderThan`, or both
|
|
177
|
+
* (a record goes when either rule says so). Returns how many were removed.
|
|
178
|
+
*/
|
|
179
|
+
prune(kind: string, opts: PruneOptions): number;
|
|
180
|
+
/**
|
|
181
|
+
* Move old records out of the active file into archive store directories
|
|
182
|
+
* named for the UTC hour each record was last written. Each archive is
|
|
183
|
+
* written and closed before the records leave the active file, so a kill in
|
|
184
|
+
* between leaves a record in both places (readers count it once) and never
|
|
185
|
+
* in neither.
|
|
186
|
+
*/
|
|
187
|
+
rotate(opts: RotateOptions): RotateReport;
|
|
188
|
+
/** Records of one module for one company. Throws when the company or namespace is missing or malformed. */
|
|
189
|
+
scope(ref: ScopeRef): ScopedLedger;
|
|
190
|
+
/** The committed namespace as this owner sees it. */
|
|
191
|
+
view(): SmartCiView;
|
|
192
|
+
/** Release ownership. Idempotent. */
|
|
193
|
+
close(): void;
|
|
194
|
+
}
|
|
195
|
+
export interface ScopedPut {
|
|
196
|
+
kind: string;
|
|
197
|
+
id: string;
|
|
198
|
+
body: Record<string, unknown>;
|
|
199
|
+
/** Bytes kept beside the record, addressed by their sha256. The record body gets a `$blob` field naming them. */
|
|
200
|
+
blob?: string | Uint8Array;
|
|
201
|
+
}
|
|
202
|
+
/** Writes and reads of one scope, through the owning ledger. */
|
|
203
|
+
export declare class ScopedLedger extends ScopedView {
|
|
204
|
+
private readonly ledger;
|
|
205
|
+
private readonly scopedPrefix;
|
|
206
|
+
private readonly scopedCompany;
|
|
207
|
+
constructor(ledger: SmartCiLedger, scopedPrefix: string, scopedCompany: string);
|
|
208
|
+
/** Write one record (and its blob, when given) in one commit. */
|
|
209
|
+
put(kind: string, id: string, body: Record<string, unknown>, opts?: {
|
|
210
|
+
blob?: string | Uint8Array;
|
|
211
|
+
}): ApplyReport;
|
|
212
|
+
/** Write several records in one commit. Blob files are written first, so a committed record never names a missing blob. */
|
|
213
|
+
putMany(puts: readonly ScopedPut[]): ApplyReport;
|
|
214
|
+
/** Remove old records of one kind (see SmartCiLedger.prune), then the blobs of this company no record names any more. */
|
|
215
|
+
prune(kind: string, opts: PruneOptions): number;
|
|
216
|
+
private sweepBlobs;
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=ledger.d.ts.map
|