@indigoai-us/hq-cli 5.345.252 → 5.345.253
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 +41 -0
- package/contracts/host-canary-release.json +5 -5
- package/dist/command-catalog.generated.d.ts +148 -0
- package/dist/command-catalog.generated.js +182 -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 +15 -0
- package/dist/commands/ci-intake.js +252 -0
- package/dist/commands/ci-metrics.d.ts +8 -0
- package/dist/commands/ci-metrics.js +55 -0
- package/dist/commands/ci.d.ts +13 -0
- package/dist/commands/ci.js +10 -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/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/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/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/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/package.json +9 -7
|
@@ -28,12 +28,14 @@ export const STORE_SCHEMA_V5 = "hq-delivery.store.v5";
|
|
|
28
28
|
export const STORE_SCHEMA_V6 = "hq-delivery.store.v6";
|
|
29
29
|
/** v7 (US-011 slice 4) adds a claim lease to every attempt (leaseExpiresAt). */
|
|
30
30
|
export const STORE_SCHEMA_V7 = "hq-delivery.store.v7";
|
|
31
|
+
/** v8 (smart-ci US-001) adds the smart-ci namespace: keyed records and stream cursors. */
|
|
32
|
+
export const STORE_SCHEMA_V8 = "hq-delivery.store.v8";
|
|
31
33
|
/** The store schema version this code writes. */
|
|
32
|
-
export const STORE_SCHEMA_VERSION =
|
|
34
|
+
export const STORE_SCHEMA_VERSION = STORE_SCHEMA_V8;
|
|
33
35
|
/** Every version this code can open, oldest first. Older ones migrate forward on open. */
|
|
34
|
-
export const KNOWN_STORE_SCHEMA_VERSIONS = [STORE_SCHEMA_V1, STORE_SCHEMA_V2, STORE_SCHEMA_V3, STORE_SCHEMA_V4, STORE_SCHEMA_V5, STORE_SCHEMA_V6, STORE_SCHEMA_V7];
|
|
36
|
+
export const KNOWN_STORE_SCHEMA_VERSIONS = [STORE_SCHEMA_V1, STORE_SCHEMA_V2, STORE_SCHEMA_V3, STORE_SCHEMA_V4, STORE_SCHEMA_V5, STORE_SCHEMA_V6, STORE_SCHEMA_V7, STORE_SCHEMA_V8];
|
|
35
37
|
const VERSION_PATTERN = /^hq-delivery\.store\.v(\d+)$/;
|
|
36
|
-
const CURRENT_VERSION_NUMBER =
|
|
38
|
+
const CURRENT_VERSION_NUMBER = 8;
|
|
37
39
|
/** Every refusal from the delivery store. The message reads "CODE: found ...; expected .... action". */
|
|
38
40
|
export class DeliveryStoreError extends Error {
|
|
39
41
|
code;
|
|
@@ -69,7 +71,7 @@ export const DECISION_CODES = [
|
|
|
69
71
|
];
|
|
70
72
|
export const OBSERVATION_SOURCES = ["apply-response", "apply-rejected", "transport-error", "stale-publication", "lease-lost", "target-query"];
|
|
71
73
|
export function emptyState() {
|
|
72
|
-
return { epoch: 0, controllers: [], runs: [], jobs: [], attempts: [], workers: [], artifacts: [], cache: [], deployments: [], deployPolicies: [] };
|
|
74
|
+
return { epoch: 0, controllers: [], runs: [], jobs: [], attempts: [], workers: [], artifacts: [], cache: [], deployments: [], deployPolicies: [], smartCi: { records: [], cursors: [] } };
|
|
73
75
|
}
|
|
74
76
|
export function stateChecksum(state) {
|
|
75
77
|
return createHash("sha256").update(JSON.stringify(state)).digest("hex");
|
|
@@ -123,8 +125,8 @@ export function parseStoreText(text, source) {
|
|
|
123
125
|
});
|
|
124
126
|
}
|
|
125
127
|
const envelope = () => readEnvelope(parsed, source);
|
|
126
|
-
const
|
|
127
|
-
?
|
|
128
|
+
const v7 = () => version === STORE_SCHEMA_V7
|
|
129
|
+
? envelope()
|
|
128
130
|
: version === STORE_SCHEMA_V6
|
|
129
131
|
? migrateV6(envelope(), source)
|
|
130
132
|
: version === STORE_SCHEMA_V5
|
|
@@ -136,6 +138,7 @@ export function parseStoreText(text, source) {
|
|
|
136
138
|
: version === STORE_SCHEMA_V2
|
|
137
139
|
? migrateV6(migrateV5(migrateV4(migrateV3(migrateV2(envelope(), source), source), source), source), source)
|
|
138
140
|
: migrateV6(migrateV5(migrateV4(migrateV1(parsed, source), source), source), source);
|
|
141
|
+
const state = version === STORE_SCHEMA_V8 ? readEnvelope(parsed, source) : migrateV7(v7(), source);
|
|
139
142
|
const errors = validateState(state);
|
|
140
143
|
if (errors.length > 0)
|
|
141
144
|
throw invalidStore(source, errors);
|
|
@@ -187,7 +190,16 @@ function migrateV6(state, source) {
|
|
|
187
190
|
});
|
|
188
191
|
return { ...state, attempts };
|
|
189
192
|
}
|
|
190
|
-
/**
|
|
193
|
+
/**
|
|
194
|
+
* v7 → v8. v8 adds the smart-ci namespace, which starts empty. Nothing else
|
|
195
|
+
* changes. The v7 checksum is checked first, by readEnvelope.
|
|
196
|
+
*/
|
|
197
|
+
function migrateV7(state, source) {
|
|
198
|
+
if ("smartCi" in state)
|
|
199
|
+
throw invalidStore(source, ["v7 state has a smartCi field; v7 has none"]);
|
|
200
|
+
return { ...state, smartCi: { records: [], cursors: [] } };
|
|
201
|
+
}
|
|
202
|
+
/** The v2 to v8 file envelope: exactly storeSchemaVersion, sha256 and state, with a matching checksum. */
|
|
191
203
|
function readEnvelope(parsed, source) {
|
|
192
204
|
const keys = Object.keys(parsed).sort().join(",");
|
|
193
205
|
if (keys !== "sha256,state,storeSchemaVersion" || typeof parsed.sha256 !== "string" || !isObject(parsed.state)) {
|
|
@@ -348,7 +360,7 @@ function checkRecord(kind, input, where, errors) {
|
|
|
348
360
|
/** All problems with a store state, or [] when it is valid. Never throws. */
|
|
349
361
|
export function validateState(input) {
|
|
350
362
|
const errors = [];
|
|
351
|
-
if (!hasExactKeys(input, ["epoch", "controllers", "runs", "jobs", "attempts", "workers", "artifacts", "cache", "deployments", "deployPolicies"], "state", errors))
|
|
363
|
+
if (!hasExactKeys(input, ["epoch", "controllers", "runs", "jobs", "attempts", "workers", "artifacts", "cache", "deployments", "deployPolicies", "smartCi"], "state", errors))
|
|
352
364
|
return errors;
|
|
353
365
|
const epoch = isCount(input.epoch) ? input.epoch : null;
|
|
354
366
|
if (epoch === null)
|
|
@@ -556,8 +568,57 @@ export function validateState(input) {
|
|
|
556
568
|
validateArtifacts(input, attemptsById, checkEpoch, errors);
|
|
557
569
|
validateDeployments(input, attemptsById, checkEpoch, errors);
|
|
558
570
|
validateDeployPolicies(input, checkEpoch, errors);
|
|
571
|
+
validateSmartCi(input, checkEpoch, errors);
|
|
559
572
|
return errors;
|
|
560
573
|
}
|
|
574
|
+
/** v8 smart-ci namespace: the record and cursor envelopes. Bodies are checked by src/lib/smart-ci. */
|
|
575
|
+
function validateSmartCi(input, checkEpoch, errors) {
|
|
576
|
+
const ns = input.smartCi;
|
|
577
|
+
if (!hasExactKeys(ns, ["records", "cursors"], "state.smartCi", errors))
|
|
578
|
+
return;
|
|
579
|
+
const isTime = (v) => v !== null && isTimeOrNull(v);
|
|
580
|
+
const seen = new Set();
|
|
581
|
+
(Array.isArray(ns.records) ? ns.records : (errors.push("state.smartCi.records: not an array"), [])).forEach((r, i) => {
|
|
582
|
+
const where = `smartCi.records[${i}]`;
|
|
583
|
+
if (!hasExactKeys(r, ["kind", "id", "recordedAt", "recordedEpoch", "updatedAt", "updatedEpoch", "body"], where, errors))
|
|
584
|
+
return;
|
|
585
|
+
if (!isText(r.kind))
|
|
586
|
+
errors.push(`${where}.kind: not a non-empty string`);
|
|
587
|
+
if (!isText(r.id))
|
|
588
|
+
errors.push(`${where}.id: not a non-empty string`);
|
|
589
|
+
if (isText(r.kind) && isText(r.id)) {
|
|
590
|
+
const key = JSON.stringify([r.kind, r.id]);
|
|
591
|
+
if (seen.has(key))
|
|
592
|
+
errors.push(`${where}: duplicate ${r.kind} record ${r.id}`);
|
|
593
|
+
seen.add(key);
|
|
594
|
+
}
|
|
595
|
+
if (!isTime(r.recordedAt))
|
|
596
|
+
errors.push(`${where}.recordedAt: not a timestamp`);
|
|
597
|
+
if (!isTime(r.updatedAt))
|
|
598
|
+
errors.push(`${where}.updatedAt: not a timestamp`);
|
|
599
|
+
checkEpoch(r.recordedEpoch, `${where}.recordedEpoch`);
|
|
600
|
+
checkEpoch(r.updatedEpoch, `${where}.updatedEpoch`);
|
|
601
|
+
if (!isObject(r.body))
|
|
602
|
+
errors.push(`${where}.body: not an object`);
|
|
603
|
+
});
|
|
604
|
+
const streams = new Set();
|
|
605
|
+
(Array.isArray(ns.cursors) ? ns.cursors : (errors.push("state.smartCi.cursors: not an array"), [])).forEach((c, i) => {
|
|
606
|
+
const where = `smartCi.cursors[${i}]`;
|
|
607
|
+
if (!hasExactKeys(c, ["stream", "position", "updatedAt", "updatedEpoch"], where, errors))
|
|
608
|
+
return;
|
|
609
|
+
if (!isText(c.stream))
|
|
610
|
+
errors.push(`${where}.stream: not a non-empty string`);
|
|
611
|
+
else if (streams.has(c.stream))
|
|
612
|
+
errors.push(`${where}: duplicate cursor for stream ${c.stream}`);
|
|
613
|
+
else
|
|
614
|
+
streams.add(c.stream);
|
|
615
|
+
if (typeof c.position !== "string")
|
|
616
|
+
errors.push(`${where}.position: not a string`);
|
|
617
|
+
if (!isTime(c.updatedAt))
|
|
618
|
+
errors.push(`${where}.updatedAt: not a timestamp`);
|
|
619
|
+
checkEpoch(c.updatedEpoch, `${where}.updatedEpoch`);
|
|
620
|
+
});
|
|
621
|
+
}
|
|
561
622
|
const isHex64 = (v) => typeof v === "string" && SHA256_HEX.test(v);
|
|
562
623
|
const isText = (v) => typeof v === "string" && v !== "";
|
|
563
624
|
/** US-008 artifact provenance and cache entries. Signatures are checked by artifacts.ts, which holds the key. */
|
|
@@ -22,8 +22,9 @@
|
|
|
22
22
|
* file, and update that file's record in test/fixtures/PROVENANCE.md.
|
|
23
23
|
*/
|
|
24
24
|
export declare const CLASSIFYING_ADAPTER_CORE_SHA256 = "cf1abd5c832722d26a46ced0694e8a3cd0d70ff30194a03fb2ce989289a8621c";
|
|
25
|
-
/** Released v16.0.51 revision
|
|
25
|
+
/** Released v16.0.51 revision, accepted by the Claude project adapter hold and by the fleet-local and agents-v2 ports. */
|
|
26
26
|
export declare const RELEASED_CLASSIFYING_ADAPTER_CORE_SHA256 = "09f5a3e05db016257f4515cf7e0101a9a34368a04c975337a5ce22f8dfe3dfb0";
|
|
27
|
+
export declare const RELEASED_CLASSIFYING_ADAPTER_CORE_FIXTURE = "adapter-stable-alias-16.0.51/core/scripts/lib/hook-adapter-core.sh";
|
|
27
28
|
/** The fixture copy of the pinned revision, under crates/hq-hook/tests/fixtures. */
|
|
28
29
|
export declare const CLASSIFYING_ADAPTER_CORE_FIXTURE = "adapter-stable-alias/core/scripts/lib/hook-adapter-core.sh";
|
|
29
30
|
//# sourceMappingURL=adapter-core-pin.d.ts.map
|
|
@@ -22,8 +22,9 @@
|
|
|
22
22
|
* file, and update that file's record in test/fixtures/PROVENANCE.md.
|
|
23
23
|
*/
|
|
24
24
|
export const CLASSIFYING_ADAPTER_CORE_SHA256 = 'cf1abd5c832722d26a46ced0694e8a3cd0d70ff30194a03fb2ce989289a8621c';
|
|
25
|
-
/** Released v16.0.51 revision
|
|
25
|
+
/** Released v16.0.51 revision, accepted by the Claude project adapter hold and by the fleet-local and agents-v2 ports. */
|
|
26
26
|
export const RELEASED_CLASSIFYING_ADAPTER_CORE_SHA256 = '09f5a3e05db016257f4515cf7e0101a9a34368a04c975337a5ce22f8dfe3dfb0';
|
|
27
|
+
export const RELEASED_CLASSIFYING_ADAPTER_CORE_FIXTURE = 'adapter-stable-alias-16.0.51/core/scripts/lib/hook-adapter-core.sh';
|
|
27
28
|
/** The fixture copy of the pinned revision, under crates/hq-hook/tests/fixtures. */
|
|
28
29
|
export const CLASSIFYING_ADAPTER_CORE_FIXTURE = 'adapter-stable-alias/core/scripts/lib/hook-adapter-core.sh';
|
|
29
30
|
//# sourceMappingURL=adapter-core-pin.js.map
|
|
@@ -185,6 +185,21 @@ export declare const SESSION_START_PINS: ReadonlyArray<readonly [string, readonl
|
|
|
185
185
|
* any revision it does not rebuild. Null when every file matches.
|
|
186
186
|
*/
|
|
187
187
|
export declare function sessionStartHold(root: string): string | null;
|
|
188
|
+
/**
|
|
189
|
+
* The script revisions the native SessionStart `migrate-policy-triggers` port rebuilds
|
|
190
|
+
* (`crates/hq-hook/src/session_start_ss1/migrate_triggers.rs`: `SCRIPT_SHA256`,
|
|
191
|
+
* `FORWARDER_SHA256`, `FORWARDER_LIB_SHA256`; hq-core v16.0.47 through v16.0.50).
|
|
192
|
+
* A missing script is skipped silently by both master-hook and the native port, so only a
|
|
193
|
+
* present file whose hash is outside the accepted set holds SessionStart on master-hook.
|
|
194
|
+
*/
|
|
195
|
+
export declare const MIGRATE_POLICY_TRIGGERS_PINS: ReadonlyArray<readonly [string, readonly string[]]>;
|
|
196
|
+
/**
|
|
197
|
+
* Why SessionStart must stay on master-hook for `migrate-policy-triggers` in `root`: the hook
|
|
198
|
+
* script is present on disk and either it or its forwarder/library is not a pinned revision.
|
|
199
|
+
* Absent hook script (or absent forwarder) is a silent no-op on both shell and native, so it
|
|
200
|
+
* does not hold. Null when every present pinned file matches.
|
|
201
|
+
*/
|
|
202
|
+
export declare function migratePolicyTriggersHold(root: string): string | null;
|
|
188
203
|
/**
|
|
189
204
|
* The one Codex adapter pair the native Codex SubagentStop is modelled on (hq-core v16.0.47):
|
|
190
205
|
* `ADAPTER_RELEASES` and `ADAPTER_CORE_RELEASES` in crates/hq-hook/src/post_hooks/codex.rs.
|
|
@@ -1743,6 +1743,11 @@ export function uncoveredHooks(root, host, event, covers, env = process.env) {
|
|
|
1743
1743
|
if (hold)
|
|
1744
1744
|
missing.push(`(native ${event} compatibility: ${hold})`);
|
|
1745
1745
|
}
|
|
1746
|
+
if (event === 'SessionStart' && covered.includes('migrate-policy-triggers')) {
|
|
1747
|
+
const hold = migratePolicyTriggersHold(root);
|
|
1748
|
+
if (hold)
|
|
1749
|
+
missing.push(`(native SessionStart compatibility: ${hold})`);
|
|
1750
|
+
}
|
|
1746
1751
|
if (host === 'agents-v2' && event === 'PreToolUse' && covered.includes('agents-v2-adapter:PreToolUse')) {
|
|
1747
1752
|
const hold = sessionStartHold(root);
|
|
1748
1753
|
if (hold)
|
|
@@ -1790,6 +1795,59 @@ export function sessionStartHold(root) {
|
|
|
1790
1795
|
}
|
|
1791
1796
|
return null;
|
|
1792
1797
|
}
|
|
1798
|
+
/**
|
|
1799
|
+
* The script revisions the native SessionStart `migrate-policy-triggers` port rebuilds
|
|
1800
|
+
* (`crates/hq-hook/src/session_start_ss1/migrate_triggers.rs`: `SCRIPT_SHA256`,
|
|
1801
|
+
* `FORWARDER_SHA256`, `FORWARDER_LIB_SHA256`; hq-core v16.0.47 through v16.0.50).
|
|
1802
|
+
* A missing script is skipped silently by both master-hook and the native port, so only a
|
|
1803
|
+
* present file whose hash is outside the accepted set holds SessionStart on master-hook.
|
|
1804
|
+
*/
|
|
1805
|
+
export const MIGRATE_POLICY_TRIGGERS_PINS = [
|
|
1806
|
+
[
|
|
1807
|
+
'.claude/hooks/migrate-policy-triggers-if-changed.sh',
|
|
1808
|
+
[
|
|
1809
|
+
'4f4cf879bf31750a87386de0db5efa6d166116da629cf2d31819b7a21faa8335',
|
|
1810
|
+
'1a01eb3c4a46bd04cc6ed7d5c465405343200b3baf391b2d1f4f393577d639f2',
|
|
1811
|
+
],
|
|
1812
|
+
],
|
|
1813
|
+
[
|
|
1814
|
+
'core/scripts/migrate-policy-triggers.sh',
|
|
1815
|
+
['9fac89fba7cc04d31aed493aee9d1a43670c0d3e570675e01be466ebe156cee6'],
|
|
1816
|
+
],
|
|
1817
|
+
[
|
|
1818
|
+
'core/scripts/lib/forwarder.sh',
|
|
1819
|
+
['a030068f482cac2ecbfad90394fd7bcd1e24926e9179bcec5c770076ad6e4fc4'],
|
|
1820
|
+
],
|
|
1821
|
+
];
|
|
1822
|
+
/**
|
|
1823
|
+
* Why SessionStart must stay on master-hook for `migrate-policy-triggers` in `root`: the hook
|
|
1824
|
+
* script is present on disk and either it or its forwarder/library is not a pinned revision.
|
|
1825
|
+
* Absent hook script (or absent forwarder) is a silent no-op on both shell and native, so it
|
|
1826
|
+
* does not hold. Null when every present pinned file matches.
|
|
1827
|
+
*/
|
|
1828
|
+
export function migratePolicyTriggersHold(root) {
|
|
1829
|
+
const hookPath = path.join(root, MIGRATE_POLICY_TRIGGERS_PINS[0][0]);
|
|
1830
|
+
if (!fs.existsSync(hookPath))
|
|
1831
|
+
return null;
|
|
1832
|
+
for (const [index, [relative, shas]] of MIGRATE_POLICY_TRIGGERS_PINS.entries()) {
|
|
1833
|
+
const file = path.join(root, relative);
|
|
1834
|
+
if (index === 1 && !fs.existsSync(file))
|
|
1835
|
+
return null;
|
|
1836
|
+
let bytes;
|
|
1837
|
+
try {
|
|
1838
|
+
if (!fs.statSync(file).isFile())
|
|
1839
|
+
return `unreadable SessionStart file ${relative}`;
|
|
1840
|
+
bytes = fs.readFileSync(file);
|
|
1841
|
+
}
|
|
1842
|
+
catch {
|
|
1843
|
+
return `unreadable SessionStart file ${relative}`;
|
|
1844
|
+
}
|
|
1845
|
+
if (!shas.includes(createHash('sha256').update(bytes).digest('hex'))) {
|
|
1846
|
+
return `unmodeled SessionStart file ${relative}`;
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
return null;
|
|
1850
|
+
}
|
|
1793
1851
|
/**
|
|
1794
1852
|
* The one Codex adapter pair the native Codex SubagentStop is modelled on (hq-core v16.0.47):
|
|
1795
1853
|
* `ADAPTER_RELEASES` and `ADAPTER_CORE_RELEASES` in crates/hq-hook/src/post_hooks/codex.rs.
|
|
@@ -1895,7 +1953,7 @@ export const GROK_STOP_OBSERVE_SESSION_ID_LEAF = 'b373b582a906b0993a3ce56aa43c1e
|
|
|
1895
1953
|
*/
|
|
1896
1954
|
export const GROK_STOP_OBSERVE_SESSION_ID_PIN = {
|
|
1897
1955
|
relative: 'core/scripts/lib/session-id.sh',
|
|
1898
|
-
accepted: ['2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d'],
|
|
1956
|
+
accepted: ['2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d', 'd6a04155571ec53edd853878cebaba5a5bab93801a73e356499440c1cd009c71'],
|
|
1899
1957
|
missing: 'allowed',
|
|
1900
1958
|
};
|
|
1901
1959
|
/**
|
|
@@ -1964,6 +2022,7 @@ export const PRE_TOOL_USE_DISPATCHER_PINS = [
|
|
|
1964
2022
|
accepted: [
|
|
1965
2023
|
'a443b481d895e74b46743548d049644ab011b1e5cb8ae3fcb8da1a6a169cd364',
|
|
1966
2024
|
'fab0ada24e4ac09e05eb5293a795f7f2bde4d58b47ac5112bfc8a5ad4900eda5',
|
|
2025
|
+
'4dd7f5296934d4488c137c9a485d4c9d55b597ee3aa2ceb6dbc3afdb0d3c1a74',
|
|
1967
2026
|
],
|
|
1968
2027
|
},
|
|
1969
2028
|
{ relative: '.claude/hooks/hook-timeout-probe.sh', accepted: ['ae5c40212c088044205e246a5715a53f52c28f4021e798bd7a74df6ba570113b'] },
|
|
@@ -2199,6 +2258,7 @@ export function promptCompanyBindHold(root) {
|
|
|
2199
2258
|
* (crates/hq-hook/src/gate/facts.rs `accepted_hook_lib_sha256`).
|
|
2200
2259
|
*/
|
|
2201
2260
|
export const POLICY_GATE_REVISIONS = [
|
|
2261
|
+
{ revision: 'Core16_0_51', gate: 'ca58a94859eae0a345c11c8d9c59303eb76350dc1cf223391037d21979c28718', hookLibs: ['9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f'] },
|
|
2202
2262
|
{ revision: 'Staging2018', gate: '1bc4df8eaabded175804d2effba704c93b439df05c0867f85bb27f5dcfbc7914', hookLibs: ['9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f'] },
|
|
2203
2263
|
{ revision: 'Core16_0_48Beta90', gate: 'a2879dfe692233f5953bac86672947bbd82f3c5247292f3efcb80f16c3d2c6b1', hookLibs: ['9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f', '49c337ceccf0a2d7c2a64f6b1de8c3c4d1da507bc5d7afcd01ed292e1f25abf7', 'be7ca74b2524afba56fefd530bf46cbd1dd39a4c181b6a64c87e124b29bdebe7'] },
|
|
2204
2264
|
{ revision: 'Core16_0_48Beta68', gate: '6005f2315210c31daf0c870b768303bfd15f58f3416c52b6e02da9bcb430e9bb', hookLibs: ['c3eb950f80aea21d3f8ad2bc0f76656e6c5a39a5197b4d985aa03d13144fc8a7'] },
|
|
@@ -2242,6 +2302,7 @@ export const GROK_POST_TOOL_USE_GENERATIONS = [
|
|
|
2242
2302
|
/** The hook-adapter-core.sh revisions of crates/hq-hook/src/host/fleet/local_pre.rs `RELEASED_CORE_SHA256`. */
|
|
2243
2303
|
export const FLEET_LOCAL_ADAPTER_CORE = [
|
|
2244
2304
|
'940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5',
|
|
2305
|
+
RELEASED_CLASSIFYING_ADAPTER_CORE_SHA256,
|
|
2245
2306
|
CLASSIFYING_ADAPTER_CORE_SHA256,
|
|
2246
2307
|
];
|
|
2247
2308
|
/**
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cost per merge (smart-ci US-001).
|
|
3
|
+
*
|
|
4
|
+
* Same method as the CI cost study of 2026-11-22
|
|
5
|
+
* (workspace/reports/ship-faster-2026-11-20/corey-ci-cost-2026-11-22.md):
|
|
6
|
+
*
|
|
7
|
+
* cost per merge = (GitHub-hosted spend + AWS runner fleet spend) / merged pull requests
|
|
8
|
+
*
|
|
9
|
+
* over one window. The study took GitHub spend from the org billing usage API
|
|
10
|
+
* and AWS spend from Cost Explorer. The ledger holds neither bill, so each
|
|
11
|
+
* input is one of two things and the output says which:
|
|
12
|
+
*
|
|
13
|
+
* - measured: counted from ledger records (merges, job minutes per pool, idle
|
|
14
|
+
* runner minutes), or a billed amount the caller passed in;
|
|
15
|
+
* - estimated: minutes multiplied by a price from the table below.
|
|
16
|
+
*
|
|
17
|
+
* The prices are list prices written down on 2026-11-24 and are estimates.
|
|
18
|
+
* Pass billed amounts to replace them. Runners on hardware Indigo owns (the Mac
|
|
19
|
+
* pool, the Windows boxes) have no price here, as in the study, and count as $0.
|
|
20
|
+
*/
|
|
21
|
+
export interface CostRates {
|
|
22
|
+
/** USD per billed minute on a GitHub-hosted runner, by OS. */
|
|
23
|
+
hostedPerMinute: {
|
|
24
|
+
linux: number;
|
|
25
|
+
windows: number;
|
|
26
|
+
macos: number;
|
|
27
|
+
};
|
|
28
|
+
/** USD per hour for one runner of an AWS pool, by pool label. */
|
|
29
|
+
awsPerHour: Record<string, number>;
|
|
30
|
+
/** USD per hour added to every AWS runner: public IPv4 and root volume. */
|
|
31
|
+
awsOverheadPerHour: number;
|
|
32
|
+
}
|
|
33
|
+
export declare const DEFAULT_RATES: CostRates;
|
|
34
|
+
export type PoolClass = "hosted-linux" | "hosted-windows" | "hosted-macos" | "aws" | "own-hardware";
|
|
35
|
+
/** Which bill a pool's minutes land on. */
|
|
36
|
+
export declare function classifyPool(pool: string, hosted: boolean, labels: readonly string[], rates: CostRates): PoolClass;
|
|
37
|
+
export interface CostInput {
|
|
38
|
+
merges: number;
|
|
39
|
+
/** Per pool: minutes jobs ran, and for hosted pools the minutes GitHub bills (each job rounded up to a whole minute). */
|
|
40
|
+
pools: Array<{
|
|
41
|
+
pool: string;
|
|
42
|
+
poolClass: PoolClass;
|
|
43
|
+
runMinutes: number;
|
|
44
|
+
billedMinutes: number;
|
|
45
|
+
}>;
|
|
46
|
+
/** Idle minutes per pool from runner samples, or null when the window has no samples. */
|
|
47
|
+
idleMinutesByPool: Record<string, number> | null;
|
|
48
|
+
/** Part of the sampled span the runner samples cover, 0 to 1; under 0.95 the idle minutes are an estimate. */
|
|
49
|
+
idleCoverage?: number | null;
|
|
50
|
+
rates: CostRates;
|
|
51
|
+
/** Billed GitHub amount for the same repo and window, when the caller has it. */
|
|
52
|
+
githubBilledUsd?: number;
|
|
53
|
+
/** AWS runner fleet amount for the same window, when the caller has it. */
|
|
54
|
+
awsFleetUsd?: number;
|
|
55
|
+
}
|
|
56
|
+
export interface CostInputNote {
|
|
57
|
+
input: string;
|
|
58
|
+
value: string;
|
|
59
|
+
basis: "measured" | "estimated" | "not counted";
|
|
60
|
+
how: string;
|
|
61
|
+
}
|
|
62
|
+
export interface CostPerMerge {
|
|
63
|
+
/** null when the window has no merges. */
|
|
64
|
+
usdPerMerge: number | null;
|
|
65
|
+
totalUsd: number;
|
|
66
|
+
githubHostedUsd: number;
|
|
67
|
+
awsUsd: number;
|
|
68
|
+
merges: number;
|
|
69
|
+
inputs: CostInputNote[];
|
|
70
|
+
}
|
|
71
|
+
export declare function costPerMerge(input: CostInput): CostPerMerge;
|
|
72
|
+
//# sourceMappingURL=cost.d.ts.map
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cost per merge (smart-ci US-001).
|
|
3
|
+
*
|
|
4
|
+
* Same method as the CI cost study of 2026-11-22
|
|
5
|
+
* (workspace/reports/ship-faster-2026-11-20/corey-ci-cost-2026-11-22.md):
|
|
6
|
+
*
|
|
7
|
+
* cost per merge = (GitHub-hosted spend + AWS runner fleet spend) / merged pull requests
|
|
8
|
+
*
|
|
9
|
+
* over one window. The study took GitHub spend from the org billing usage API
|
|
10
|
+
* and AWS spend from Cost Explorer. The ledger holds neither bill, so each
|
|
11
|
+
* input is one of two things and the output says which:
|
|
12
|
+
*
|
|
13
|
+
* - measured: counted from ledger records (merges, job minutes per pool, idle
|
|
14
|
+
* runner minutes), or a billed amount the caller passed in;
|
|
15
|
+
* - estimated: minutes multiplied by a price from the table below.
|
|
16
|
+
*
|
|
17
|
+
* The prices are list prices written down on 2026-11-24 and are estimates.
|
|
18
|
+
* Pass billed amounts to replace them. Runners on hardware Indigo owns (the Mac
|
|
19
|
+
* pool, the Windows boxes) have no price here, as in the study, and count as $0.
|
|
20
|
+
*/
|
|
21
|
+
export const DEFAULT_RATES = {
|
|
22
|
+
hostedPerMinute: { linux: 0.006, windows: 0.01, macos: 0.062 },
|
|
23
|
+
awsPerHour: {
|
|
24
|
+
"hq-cli-main-priority": 0.1795,
|
|
25
|
+
"hq-pr-pool-hq-cli": 0.1795,
|
|
26
|
+
"hq-cli-x64": 0.1058,
|
|
27
|
+
"hq-pro-main-ec2": 0.359,
|
|
28
|
+
"hq-pro-main-priority": 0.359,
|
|
29
|
+
"hq-pro-agents-main-ec2": 0.359,
|
|
30
|
+
"hq-cloud-bench-x64": 0.1058,
|
|
31
|
+
"indigo-arm64": 0.0898,
|
|
32
|
+
"indigo-x64": 0.1058,
|
|
33
|
+
"aws-local-ci": 0.319,
|
|
34
|
+
"aws-linux": 0.319,
|
|
35
|
+
},
|
|
36
|
+
awsOverheadPerHour: 0.0094,
|
|
37
|
+
};
|
|
38
|
+
/** Which bill a pool's minutes land on. */
|
|
39
|
+
export function classifyPool(pool, hosted, labels, rates) {
|
|
40
|
+
if (hosted) {
|
|
41
|
+
const all = [pool, ...labels].join(" ").toLowerCase();
|
|
42
|
+
if (all.includes("macos"))
|
|
43
|
+
return "hosted-macos";
|
|
44
|
+
if (all.includes("windows"))
|
|
45
|
+
return "hosted-windows";
|
|
46
|
+
return "hosted-linux";
|
|
47
|
+
}
|
|
48
|
+
return Object.prototype.hasOwnProperty.call(rates.awsPerHour, pool) ? "aws" : "own-hardware";
|
|
49
|
+
}
|
|
50
|
+
const usd = (n) => `$${n.toFixed(2)}`;
|
|
51
|
+
const mins = (n) => `${n.toFixed(1)} min`;
|
|
52
|
+
export function costPerMerge(input) {
|
|
53
|
+
const { rates } = input;
|
|
54
|
+
const inputs = [];
|
|
55
|
+
inputs.push({ input: "Merged pull requests", value: String(input.merges), basis: "measured", how: "pull request records in the ledger with a merge time in the window" });
|
|
56
|
+
const hosted = input.pools.filter((p) => p.poolClass.startsWith("hosted-"));
|
|
57
|
+
const hostedBilledMinutes = hosted.reduce((s, p) => s + p.billedMinutes, 0);
|
|
58
|
+
let githubHostedUsd;
|
|
59
|
+
if (input.githubBilledUsd !== undefined) {
|
|
60
|
+
githubHostedUsd = input.githubBilledUsd;
|
|
61
|
+
inputs.push({ input: "GitHub-hosted spend", value: usd(githubHostedUsd), basis: "measured", how: "billed amount passed in (GitHub billing usage API), as in the 2026-11-22 study" });
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
githubHostedUsd = hosted.reduce((s, p) => {
|
|
65
|
+
const os = p.poolClass === "hosted-macos" ? "macos" : p.poolClass === "hosted-windows" ? "windows" : "linux";
|
|
66
|
+
return s + p.billedMinutes * rates.hostedPerMinute[os];
|
|
67
|
+
}, 0);
|
|
68
|
+
inputs.push({ input: "GitHub-hosted minutes", value: mins(hostedBilledMinutes), basis: "measured", how: "job records on GitHub-hosted runners, each job rounded up to a whole minute" });
|
|
69
|
+
inputs.push({
|
|
70
|
+
input: "GitHub-hosted spend",
|
|
71
|
+
value: usd(githubHostedUsd),
|
|
72
|
+
basis: "estimated",
|
|
73
|
+
how: `minutes x list price (Linux $${rates.hostedPerMinute.linux}, Windows $${rates.hostedPerMinute.windows}, macOS $${rates.hostedPerMinute.macos} a minute); no billed amount was passed in`,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const aws = input.pools.filter((p) => p.poolClass === "aws");
|
|
77
|
+
const awsRunMinutes = aws.reduce((s, p) => s + p.runMinutes, 0);
|
|
78
|
+
const idle = input.idleMinutesByPool;
|
|
79
|
+
const awsIdleMinutes = idle === null ? 0 : Object.entries(idle).reduce((s, [pool, m]) => s + (Object.prototype.hasOwnProperty.call(rates.awsPerHour, pool) ? m : 0), 0);
|
|
80
|
+
let awsUsd;
|
|
81
|
+
if (input.awsFleetUsd !== undefined) {
|
|
82
|
+
awsUsd = input.awsFleetUsd;
|
|
83
|
+
inputs.push({ input: "AWS runner fleet spend", value: usd(awsUsd), basis: "measured", how: "amount passed in (AWS Cost Explorer for the runner fleet), as in the 2026-11-22 study; pass this repo's share, or read the result as fleet spend over this repo's merges" });
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
const rate = (pool) => (rates.awsPerHour[pool] ?? 0) + rates.awsOverheadPerHour;
|
|
87
|
+
const runUsd = aws.reduce((s, p) => s + (p.runMinutes / 60) * rate(p.pool), 0);
|
|
88
|
+
const idleUsd = idle === null ? 0 : Object.entries(idle).reduce((s, [pool, m]) => s + (Object.prototype.hasOwnProperty.call(rates.awsPerHour, pool) ? (m / 60) * rate(pool) : 0), 0);
|
|
89
|
+
awsUsd = runUsd + idleUsd;
|
|
90
|
+
inputs.push({ input: "AWS runner minutes running jobs", value: mins(awsRunMinutes), basis: "measured", how: "job records on AWS pools" });
|
|
91
|
+
inputs.push(idle === null
|
|
92
|
+
? { input: "AWS runner minutes idle", value: "none", basis: "not counted", how: "the window has no runner pool samples, so idle and warm-pool time is missing from this cost" }
|
|
93
|
+
: (input.idleCoverage ?? 1) >= 0.95
|
|
94
|
+
? { input: "AWS runner minutes idle", value: mins(awsIdleMinutes), basis: "measured", how: "runner pool samples: idle runners x time between samples, times this repo's share of the recorded run minutes on each pool" }
|
|
95
|
+
: {
|
|
96
|
+
input: "AWS runner minutes idle",
|
|
97
|
+
value: mins(awsIdleMinutes),
|
|
98
|
+
basis: "estimated",
|
|
99
|
+
how: `runner pool samples cover ${Math.round((input.idleCoverage ?? 0) * 100)}% of the sampled time (samples were skipped), so this is a lower bound; idle runners x time between samples, times this repo's share of the recorded run minutes on each pool`,
|
|
100
|
+
});
|
|
101
|
+
inputs.push({
|
|
102
|
+
input: "AWS runner fleet spend",
|
|
103
|
+
value: usd(awsUsd),
|
|
104
|
+
basis: "estimated",
|
|
105
|
+
how: "minutes x On-Demand list price per pool plus IPv4 and disk; boot time, Spot discounts and data transfer are not in it; no Cost Explorer amount was passed in",
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
const own = input.pools.filter((p) => p.poolClass === "own-hardware");
|
|
109
|
+
if (own.length > 0) {
|
|
110
|
+
inputs.push({
|
|
111
|
+
input: "Runners on owned hardware",
|
|
112
|
+
value: mins(own.reduce((s, p) => s + p.runMinutes, 0)),
|
|
113
|
+
basis: "not counted",
|
|
114
|
+
how: `pools ${own.map((p) => p.pool).sort().join(", ")} have no price (the 2026-11-22 study also left the Mac pool out); counted as $0`,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
const totalUsd = githubHostedUsd + awsUsd;
|
|
118
|
+
return { usdPerMerge: input.merges > 0 ? totalUsd / input.merges : null, totalUsd, githubHostedUsd, awsUsd, merges: input.merges, inputs };
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=cost.js.map
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
export declare const GITHUB_API = "https://api.github.com";
|
|
2
|
+
export declare class GitHubReadError extends Error {
|
|
3
|
+
readonly status: number;
|
|
4
|
+
readonly path: string;
|
|
5
|
+
/** Seconds to wait before another request, when GitHub said so. */
|
|
6
|
+
readonly retryAfterSeconds: number | null;
|
|
7
|
+
constructor(message: string, status: number, path: string,
|
|
8
|
+
/** Seconds to wait before another request, when GitHub said so. */
|
|
9
|
+
retryAfterSeconds?: number | null);
|
|
10
|
+
}
|
|
11
|
+
export interface AuditEntry {
|
|
12
|
+
ts: string;
|
|
13
|
+
method: "GET";
|
|
14
|
+
path: string;
|
|
15
|
+
status: number;
|
|
16
|
+
conditional: boolean;
|
|
17
|
+
rateRemaining: number | null;
|
|
18
|
+
rateUsed: number | null;
|
|
19
|
+
}
|
|
20
|
+
export interface GitHubResponse {
|
|
21
|
+
status: number;
|
|
22
|
+
/** True for 304: nothing changed since the last read of this path. */
|
|
23
|
+
notModified: boolean;
|
|
24
|
+
/** Parsed JSON body, or null on 304. */
|
|
25
|
+
body: unknown;
|
|
26
|
+
/** Query string of the next page from the Link header (GitHub links by repository id, so the caller keeps its own path), or null. */
|
|
27
|
+
nextQuery: string | null;
|
|
28
|
+
}
|
|
29
|
+
export type FetchLike = (url: string, init: {
|
|
30
|
+
method: "GET";
|
|
31
|
+
headers: Record<string, string>;
|
|
32
|
+
}) => Promise<{
|
|
33
|
+
status: number;
|
|
34
|
+
headers: {
|
|
35
|
+
get(name: string): string | null;
|
|
36
|
+
};
|
|
37
|
+
text(): Promise<string>;
|
|
38
|
+
}>;
|
|
39
|
+
export interface GitHubClientOptions {
|
|
40
|
+
token: string;
|
|
41
|
+
/** Default https://api.github.com. Tests point this at a local server. */
|
|
42
|
+
baseUrl?: string;
|
|
43
|
+
fetch?: FetchLike;
|
|
44
|
+
clock?: () => number;
|
|
45
|
+
/** Append one JSON line per request here. */
|
|
46
|
+
auditPath?: string;
|
|
47
|
+
/** Size at which the audit log is rotated to `<auditPath>.1`. Default 16 MB (about 100,000 requests). */
|
|
48
|
+
auditMaxBytes?: number;
|
|
49
|
+
/** Called with each audit entry, after it is written. */
|
|
50
|
+
onRequest?: (entry: AuditEntry) => void;
|
|
51
|
+
userAgent?: string;
|
|
52
|
+
}
|
|
53
|
+
/** How many requests were made, in total and in the last hour. */
|
|
54
|
+
export interface RequestCounts {
|
|
55
|
+
total: number;
|
|
56
|
+
notModified: number;
|
|
57
|
+
errors: number;
|
|
58
|
+
lastHour: number;
|
|
59
|
+
/** Requests in the last hour that were not answered 304: the ones that count against the rate limit. */
|
|
60
|
+
lastHourCounted: number;
|
|
61
|
+
rateRemaining: number | null;
|
|
62
|
+
}
|
|
63
|
+
export declare class GitHubReadClient {
|
|
64
|
+
private readonly token;
|
|
65
|
+
private readonly baseUrl;
|
|
66
|
+
private readonly fetchImpl;
|
|
67
|
+
private readonly clock;
|
|
68
|
+
private readonly auditPath;
|
|
69
|
+
private readonly auditMaxBytes;
|
|
70
|
+
private auditBytes;
|
|
71
|
+
private readonly onRequest;
|
|
72
|
+
private readonly userAgent;
|
|
73
|
+
private readonly etags;
|
|
74
|
+
private readonly recent;
|
|
75
|
+
private total;
|
|
76
|
+
private notModified;
|
|
77
|
+
private errors;
|
|
78
|
+
private rateRemaining;
|
|
79
|
+
private rateResetAt;
|
|
80
|
+
constructor(opts: GitHubClientOptions);
|
|
81
|
+
/**
|
|
82
|
+
* GET one allowed path. With `conditional` (the default) a known ETag is sent
|
|
83
|
+
* and a 304 comes back as notModified. Throws GitHubReadError for any other
|
|
84
|
+
* status than 200 or 304.
|
|
85
|
+
*/
|
|
86
|
+
get(path: string, opts?: {
|
|
87
|
+
conditional?: boolean;
|
|
88
|
+
}): Promise<GitHubResponse>;
|
|
89
|
+
/** Forget the ETag of a path, so the next read returns the body again. */
|
|
90
|
+
forget(path: string): void;
|
|
91
|
+
/** Forget every ETag: what was read since the last commit did not reach the ledger. */
|
|
92
|
+
forgetAll(): void;
|
|
93
|
+
/** Charged requests (every answer but a 304) of the last hour, by clock minute, oldest first. */
|
|
94
|
+
chargedByMinute(): Array<[number, number]>;
|
|
95
|
+
private nextQuery;
|
|
96
|
+
private record;
|
|
97
|
+
counts(): RequestCounts;
|
|
98
|
+
/** When GitHub's rate window resets, in clock milliseconds, or null when not yet known. */
|
|
99
|
+
rateResetsAt(): number | null;
|
|
100
|
+
}
|
|
101
|
+
/** Read an audit log and count its requests. Any method other than GET is a write call. */
|
|
102
|
+
export declare function summarizeAudit(lines: readonly string[]): {
|
|
103
|
+
requests: number;
|
|
104
|
+
writes: number;
|
|
105
|
+
notModified: number;
|
|
106
|
+
byStatus: Record<string, number>;
|
|
107
|
+
firstAt: string | null;
|
|
108
|
+
lastAt: string | null;
|
|
109
|
+
perHour: number | null;
|
|
110
|
+
countedPerHour: number | null;
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=github.d.ts.map
|