@indigoai-us/hq-cli 5.345.272 → 5.345.274
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 +25 -0
- package/contracts/host-canary-release.json +8 -7
- package/dist/lib/daemon/merge-sections.d.ts +24 -1
- package/dist/lib/daemon/merge-sections.js +59 -11
- package/dist/lib/daemon/run.js +2 -2
- package/dist/lib/hook-engine/canary-gate.d.ts +2 -0
- package/dist/lib/hook-engine/canary-gate.js +22 -2
- package/dist/lib/hook-engine/coverage.d.ts +1 -1
- package/dist/lib/hook-engine/coverage.js +2 -1
- package/dist/lib/hook-engine/native-stop-compatibility.json +2 -1
- package/dist/lib/hook-engine/stable-link.d.ts +21 -0
- package/dist/lib/hook-engine/stable-link.js +37 -0
- package/package.json +7 -7
- package/scripts/install-hook-engine.mjs +24 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [5.345.274] — 2026-12-01
|
|
6
|
+
- Move `a_company_post_tool_use_hook_past_two_seconds_is_killed_alike_on_both_paths` (an 8+ s real `sleep 30` child-kill test in `agents_v2_post_tool_use_parity.rs`) into `HQ_HOOK_REAL_TIME_FILTER` in both `hq-hook-pr.yml` and `hq-hook-macos-pr.yml` so it runs on the daily schedule instead of PR shards.
|
|
7
|
+
- Changed: with the repository variable HQ_MACOS_PER_BATCH set to on, the native macOS hq-hook tests run once per batch train commit (the whole PR tier) instead of on every pull request push, and the batch train merges a batch that reaches the hook paths only when that check passed on the train commit. A pull request runs them on demand with the run-macos-native label. Unset, nothing changes.
|
|
8
|
+
- Fixed auto-checkpoint-trigger git dirty detection to treat binary files (NUL byte within the first 8,000 bytes) under `text=auto` or `core.autocrlf` as stored as-is, preventing false refusals on racy-clean image assets while keeping explicit `text` and CRLF text files fail-closed.
|
|
9
|
+
- Fixed host-canary snapshot creation to include an empty companies/ directory so disposable snapshots satisfy HQ-root validation without copying live company data.
|
|
10
|
+
- Fixed: `hq-hook run --host` now honors per-port `hook-engine-port-*` flags (all 18 `HOOK_IDS`) using the shared `snapshot-v2` / daemon-state reader with the 15-minute freshness bound and logs per-port mode entries to `~/.hq/logs/hook-engine.jsonl`. An explicit `false` override runs the hook's bash script when present on disk; when no bash script is present, guard ports stay native (`fallback_unavailable_kept_native`) and non-guard ports skip (`skipped`).
|
|
11
|
+
- Fixed: Explicit reinstall of an older `@indigoai-us/hq-cli` version now moves `~/.hq/bin/hq-hook/stable` back to that version's hook engine during postinstall, while accidental downgrades from other callers remain refused.
|
|
12
|
+
- Isolate the shell and native test roots in `agents_v2_session_end::a_hung_hook_under_the_p347_budget_clock_is_handed_back_and_skipped_by_name` so a late orphaned child from the timed-out shell run cannot race into the native run's marker file under runner load.
|
|
13
|
+
- Updated `contracts/host-canary-release.json` with the Claude Code host canary records for hq-cli 5.345.274.
|
|
14
|
+
- Changed: native hooks accept the next hq-core `.claude/hooks/master-hook.sh` (`0ab08d73`, `hq-core-staging#2192`), which drops an unused engine call, for PreToolUse and Stop.
|
|
15
|
+
- Decouple the `hq-hook` source build digest from `package.json` version bumps and key `scripts/release-canary.mjs` and `src/lib/hook-engine/canary-gate.ts` to the hook-engine source tree hash (`engineSourceSha256`), so unchanged hook-engine releases reuse a fresh passing canary end-to-end while failing closed whenever any hook-engine source input or build target changes.
|
|
16
|
+
- The agents-v2 company hook cut test now runs at a 200 ms per-hook limit that only test builds can set, so it no longer waits on a real 2-second limit; a new test checks that a PreToolUse hook cut at that limit still blocks.
|
|
17
|
+
- Split the agents-v2 company PostToolUse hook test so its refusal and crash cases no longer share one call with a 1-second hook timeout, so the macOS hook tests stop failing on busy build Macs.
|
|
18
|
+
- Set `HQ_HOOK_DEDUPE_WINDOW=60` in `folder_hooks_codex_grok_lifecycle_parity.rs` (matching `session_start_master.rs` and `agents_v2_subagent_stop_parity.rs`) so the twin-event parity test checks lock sharing rather than the default 5 s wall-clock window under runner load.
|
|
19
|
+
- Bind the `Rng::pick` result before passing it to `pem` in the PostToolUse output-redaction test suite so the test target compiles on Rust 1.95.0 and passes Clippy on Rust 1.100.0.
|
|
20
|
+
- Fix two load-sensitive timing flakes in `hq-hook` tests: refresh the synthetic 12 s `refreshed_at` timestamp in `fleet_merge_hold_parity.rs` right before the native `hq-hook` invocation so a slow bash pass cannot expire the 20 s window before `hq-hook` starts, and clear `HQD_SHIM_DEADLINE_MS` in a transparent `perl` wrapper for `Daemon::Busy` in `session_start_hqd_open.rs` so bash startup under load does not expire the 300 ms shim budget before `perl` connects.
|
|
21
|
+
|
|
22
|
+
## [5.345.273] — 2026-12-01
|
|
23
|
+
- Fixed: hosted agents (`agents-v2`) on the v2.71 release-line hook adapter that carries the `hq-agents-v2` #364 PreToolUse payload fix (`b6db50be`) keep native hook registration. `hq-hook` now answers `PreToolUse`, `PostToolUse`, `UserPromptSubmit`, `SessionStart`, `SessionEnd` and `SubagentStop` natively for that adapter, as it already does for the main-line #364 adapter (`15fa77e8`), and still hands `Stop` to the adapter. An adapter revision `hq-hook` does not know still runs every event through the adapter, and the reason it gives no longer names only #332.
|
|
24
|
+
- Updated `contracts/host-canary-release.json` with the Claude Code host canary records for hq-cli 5.345.273.
|
|
25
|
+
- CI: the hq-hook macOS native tests on a pull request now start after the Linux hq-hook tests pass on the same commit, and do not run again on a commit they already passed on.
|
|
26
|
+
- Fixed: `gh pr merge` no longer stops with "merge state unreadable" only because the daemon's merge state is a little over a minute old. In that case the merge gate asks `hq runners hold check` directly and follows its answer. The daemon now keeps flag values fresh in the background, so building that state no longer waits on slow flag reads.
|
|
27
|
+
- Speed up npm releases by building native `hq-hook` packages in parallel with the tag parity check (while still gating all npm publication on parity) and inheriting verified green `hq-hook` CI across commits that only update `contracts/host-canary-release.json`.
|
|
28
|
+
- Use Windows PowerShell (`shell: powershell`) for the self-hosted Windows `verify-published` signature check in `.github/workflows/hq-hook-packages.yml`, matching the shell shipped on `hq-windows` runners.
|
|
29
|
+
|
|
5
30
|
## [5.345.272] — 2026-11-30
|
|
6
31
|
- Set explicit file timestamps in auto-checkpoint tests to remove fixture sleeps.
|
|
7
32
|
- Fix a flaky `hq core checkpoint` test that failed when a real process held the PID its spawn mock reported.
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": "hq.host-canary-release.v1",
|
|
3
|
-
"cliVersion": "5.345.
|
|
3
|
+
"cliVersion": "5.345.274",
|
|
4
|
+
"engineSourceSha256": "819bcbe74ce86e558fc8ffc97ad39d1967bec108866a1be4c59ef779a6ed5db2",
|
|
4
5
|
"hosts": {
|
|
5
6
|
"claude": [
|
|
6
7
|
{
|
|
7
8
|
"passed": true,
|
|
8
|
-
"at": "2026-
|
|
9
|
-
"engineVersion": "0.3.1+hq.5.345.
|
|
9
|
+
"at": "2026-12-01T01:49:19.303Z",
|
|
10
|
+
"engineVersion": "0.3.1+hq.5.345.274.src.26bc267875a24662656ea518ef7f7a702c6327c741ceafdcc4f4f5a48cb770dc",
|
|
10
11
|
"gateSha256": "a2879dfe692233f5953bac86672947bbd82f3c5247292f3efcb80f16c3d2c6b1"
|
|
11
12
|
},
|
|
12
13
|
{
|
|
13
14
|
"passed": true,
|
|
14
|
-
"at": "2026-
|
|
15
|
-
"engineVersion": "0.3.1+hq.5.345.
|
|
15
|
+
"at": "2026-12-01T01:49:53.957Z",
|
|
16
|
+
"engineVersion": "0.3.1+hq.5.345.274.src.26bc267875a24662656ea518ef7f7a702c6327c741ceafdcc4f4f5a48cb770dc",
|
|
16
17
|
"gateSha256": "ca58a94859eae0a345c11c8d9c59303eb76350dc1cf223391037d21979c28718"
|
|
17
18
|
},
|
|
18
19
|
{
|
|
19
20
|
"passed": true,
|
|
20
|
-
"at": "2026-
|
|
21
|
-
"engineVersion": "0.3.1+hq.5.345.
|
|
21
|
+
"at": "2026-12-01T01:50:49.692Z",
|
|
22
|
+
"engineVersion": "0.3.1+hq.5.345.274.src.26bc267875a24662656ea518ef7f7a702c6327c741ceafdcc4f4f5a48cb770dc",
|
|
22
23
|
"gateSha256": "ecdbab7c2e0a1d94eb9c98f15e760390f215bc7115a217ded24b4275322722d2"
|
|
23
24
|
}
|
|
24
25
|
]
|
|
@@ -65,8 +65,18 @@ export declare const MERGE_SECTION_MAX_AGE_SECONDS = 60;
|
|
|
65
65
|
export declare const MERGE_SECTION_REFRESH_INTERVAL_MS = 15000;
|
|
66
66
|
/** A flag value is asked of the registry again after this long. */
|
|
67
67
|
export declare const MERGE_FLAG_TTL_MS = 30000;
|
|
68
|
+
/**
|
|
69
|
+
* The daemon's reader re-reads a kept flag value in the background once it is
|
|
70
|
+
* this old, and keeps answering with it until MERGE_FLAG_TTL_MS, so a build
|
|
71
|
+
* does not wait on the registry while a value is kept. On 2026-11-30 the
|
|
72
|
+
* state file was written 4 to 52 s after the build that stamped its sections
|
|
73
|
+
* started, and the native merge gate refuses a section past 60 s.
|
|
74
|
+
*/
|
|
75
|
+
export declare const MERGE_FLAG_REFRESH_AHEAD_MS = 15000;
|
|
68
76
|
/** A flag read that takes longer than this counts as unreadable. */
|
|
69
77
|
export declare const MERGE_FLAG_READ_TIMEOUT_MS = 12000;
|
|
78
|
+
/** A section build that takes longer than this is logged with its time. */
|
|
79
|
+
export declare const MERGE_SECTION_SLOW_BUILD_MS = 5000;
|
|
70
80
|
export interface MergeHoldEntry {
|
|
71
81
|
repo: string;
|
|
72
82
|
reason: string;
|
|
@@ -169,11 +179,24 @@ export declare function foldDecisionQueue(text: string): FoldedQueue;
|
|
|
169
179
|
export declare function mergeApprovalsSectionBytes(section: MergeApprovalsSection): number;
|
|
170
180
|
/** The merge_approvals section, or null to leave it out of the state file. */
|
|
171
181
|
export declare function buildMergeApprovalsSection(input: MergeSectionInput): Promise<MergeApprovalsSection | null>;
|
|
172
|
-
/**
|
|
182
|
+
/**
|
|
183
|
+
* Both sections, read at `input.now`. A builder that throws leaves its section
|
|
184
|
+
* out. A builder slower than MERGE_SECTION_SLOW_BUILD_MS is logged with its
|
|
185
|
+
* time: its section's refreshed_at is the build's start, so that time comes
|
|
186
|
+
* off the section's 60 s life before the state file is even written.
|
|
187
|
+
*/
|
|
173
188
|
export declare function buildMergeSections(input: MergeSectionInput): Promise<MergeSections>;
|
|
174
189
|
export interface RegistryMergeFlagReaderOptions {
|
|
175
190
|
env: NodeJS.ProcessEnv;
|
|
176
191
|
ttlMs?: number;
|
|
192
|
+
/**
|
|
193
|
+
* When set, a kept value at least this old (and younger than `ttlMs`) is
|
|
194
|
+
* answered at once and read again in the background, one read per flag and
|
|
195
|
+
* company at a time. A background read that fails leaves the kept value to
|
|
196
|
+
* expire at `ttlMs`, as it would have without the read. Unset: a kept value
|
|
197
|
+
* is answered until `ttlMs` and never read early.
|
|
198
|
+
*/
|
|
199
|
+
refreshAheadMs?: number;
|
|
177
200
|
timeoutMs?: number;
|
|
178
201
|
now?: () => number;
|
|
179
202
|
/** Test seam: one registry read; null when it could not be read. */
|
|
@@ -75,8 +75,18 @@ export const MERGE_SECTION_MAX_AGE_SECONDS = 60;
|
|
|
75
75
|
export const MERGE_SECTION_REFRESH_INTERVAL_MS = 15_000;
|
|
76
76
|
/** A flag value is asked of the registry again after this long. */
|
|
77
77
|
export const MERGE_FLAG_TTL_MS = 30_000;
|
|
78
|
+
/**
|
|
79
|
+
* The daemon's reader re-reads a kept flag value in the background once it is
|
|
80
|
+
* this old, and keeps answering with it until MERGE_FLAG_TTL_MS, so a build
|
|
81
|
+
* does not wait on the registry while a value is kept. On 2026-11-30 the
|
|
82
|
+
* state file was written 4 to 52 s after the build that stamped its sections
|
|
83
|
+
* started, and the native merge gate refuses a section past 60 s.
|
|
84
|
+
*/
|
|
85
|
+
export const MERGE_FLAG_REFRESH_AHEAD_MS = 15_000;
|
|
78
86
|
/** A flag read that takes longer than this counts as unreadable. */
|
|
79
87
|
export const MERGE_FLAG_READ_TIMEOUT_MS = 12_000;
|
|
88
|
+
/** A section build that takes longer than this is logged with its time. */
|
|
89
|
+
export const MERGE_SECTION_SLOW_BUILD_MS = 5_000;
|
|
80
90
|
const LINK_ID_RE = /^[A-Za-z0-9._-]{1,200}$/;
|
|
81
91
|
const REPO_RE = /^[a-z0-9_.-]+\/[a-z0-9_.-]+$/;
|
|
82
92
|
const HEAD_SHA_RE = /^[0-9a-f]{40}$/;
|
|
@@ -633,11 +643,28 @@ export async function buildMergeApprovalsSection(input) {
|
|
|
633
643
|
conduct.close();
|
|
634
644
|
}
|
|
635
645
|
}
|
|
636
|
-
/**
|
|
646
|
+
/**
|
|
647
|
+
* Both sections, read at `input.now`. A builder that throws leaves its section
|
|
648
|
+
* out. A builder slower than MERGE_SECTION_SLOW_BUILD_MS is logged with its
|
|
649
|
+
* time: its section's refreshed_at is the build's start, so that time comes
|
|
650
|
+
* off the section's 60 s life before the state file is even written.
|
|
651
|
+
*/
|
|
637
652
|
export async function buildMergeSections(input) {
|
|
653
|
+
const timed = async (name, build) => {
|
|
654
|
+
const started = performance.now();
|
|
655
|
+
try {
|
|
656
|
+
return await build().catch(() => null);
|
|
657
|
+
}
|
|
658
|
+
finally {
|
|
659
|
+
const ms = Math.round(performance.now() - started);
|
|
660
|
+
if (ms > MERGE_SECTION_SLOW_BUILD_MS) {
|
|
661
|
+
input.log?.("info", `merge section ${name} took ${ms} ms to build; its refreshed_at is the build's start`);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
};
|
|
638
665
|
const [holds, approvals] = await Promise.all([
|
|
639
|
-
|
|
640
|
-
|
|
666
|
+
timed("merge_holds", () => buildMergeHoldsSection(input)),
|
|
667
|
+
timed("merge_approvals", () => buildMergeApprovalsSection(input)),
|
|
641
668
|
]);
|
|
642
669
|
return { merge_holds: holds, merge_approvals: approvals };
|
|
643
670
|
}
|
|
@@ -676,12 +703,10 @@ export function createRegistryMergeFlagReader(options) {
|
|
|
676
703
|
const timeoutMs = options.timeoutMs ?? MERGE_FLAG_READ_TIMEOUT_MS;
|
|
677
704
|
const now = options.now ?? (() => performance.now());
|
|
678
705
|
const read = options.read ?? registryRead;
|
|
706
|
+
const refreshAheadMs = options.refreshAheadMs;
|
|
679
707
|
const held = new Map();
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
const kept = held.get(key);
|
|
683
|
-
if (kept && now() - kept.at < ttlMs)
|
|
684
|
-
return kept.value;
|
|
708
|
+
const reading = new Map();
|
|
709
|
+
const readNow = async (flag, company) => {
|
|
685
710
|
const startedAt = now();
|
|
686
711
|
let timer;
|
|
687
712
|
const timeout = new Promise((resolve) => {
|
|
@@ -705,12 +730,35 @@ export function createRegistryMergeFlagReader(options) {
|
|
|
705
730
|
finally {
|
|
706
731
|
clearTimeout(timer);
|
|
707
732
|
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
else
|
|
733
|
+
const key = JSON.stringify([flag, company.uid, company.slug]);
|
|
734
|
+
if (value !== null)
|
|
711
735
|
held.set(key, { at: startedAt, value });
|
|
736
|
+
// A failed read is never kept. A kept value it would replace expires at
|
|
737
|
+
// ttlMs as before: drop it only once it has.
|
|
738
|
+
else if (!(held.get(key) && now() - held.get(key).at < ttlMs))
|
|
739
|
+
held.delete(key);
|
|
712
740
|
return value;
|
|
713
741
|
};
|
|
742
|
+
// One read per flag and company at a time.
|
|
743
|
+
const readOnce = (key, flag, company) => {
|
|
744
|
+
let pending = reading.get(key);
|
|
745
|
+
if (!pending) {
|
|
746
|
+
pending = readNow(flag, company).finally(() => reading.delete(key));
|
|
747
|
+
reading.set(key, pending);
|
|
748
|
+
}
|
|
749
|
+
return pending;
|
|
750
|
+
};
|
|
751
|
+
return async (flag, company) => {
|
|
752
|
+
const key = JSON.stringify([flag, company.uid, company.slug]);
|
|
753
|
+
const kept = held.get(key);
|
|
754
|
+
if (kept && now() - kept.at < ttlMs) {
|
|
755
|
+
if (refreshAheadMs !== undefined && now() - kept.at >= refreshAheadMs) {
|
|
756
|
+
void readOnce(key, flag, company).catch(() => { });
|
|
757
|
+
}
|
|
758
|
+
return kept.value;
|
|
759
|
+
}
|
|
760
|
+
return readOnce(key, flag, company);
|
|
761
|
+
};
|
|
714
762
|
}
|
|
715
763
|
/**
|
|
716
764
|
* Rebuild both sections now and then every `intervalMs` after the previous
|
package/dist/lib/daemon/run.js
CHANGED
|
@@ -69,7 +69,7 @@ import { needsWindowsTaskRelaunch, scheduleWindowsTaskRelaunch } from "./windows
|
|
|
69
69
|
import { detectMachineType } from "./machine-type.js";
|
|
70
70
|
import { appendPrivate, daemonPaths, ensurePrivateDir, openPrivateAppend } from "./paths.js";
|
|
71
71
|
import { SELF_CHECK_RESULT_FILE, readSelfCheckResult } from "./selfcheck.js";
|
|
72
|
-
import { createRegistryMergeFlagReader, startMergeSectionRefresh } from "./merge-sections.js";
|
|
72
|
+
import { createRegistryMergeFlagReader, MERGE_FLAG_REFRESH_AHEAD_MS, startMergeSectionRefresh } from "./merge-sections.js";
|
|
73
73
|
import { createDaemonStateWriter, daemonStateFilePath, defaultDaemonStateFilePath, readVaultAccessManifest, selfCheckMachineChecks, } from "./state-file.js";
|
|
74
74
|
import { hqdSocketPath } from "./protocol.js";
|
|
75
75
|
import { startHqdServer, syncHqdEnabledMarker } from "./server.js";
|
|
@@ -1245,7 +1245,7 @@ export async function runDaemon(opts) {
|
|
|
1245
1245
|
// between the 30-second registry requests (merge-sections.ts).
|
|
1246
1246
|
const mergeSections = startMergeSectionRefresh({
|
|
1247
1247
|
hqRoot: () => readDaemonConfig(paths.configPath).hqRoot ?? (env.HQ_ROOT?.trim() || undefined),
|
|
1248
|
-
readFlag: createRegistryMergeFlagReader({ env }),
|
|
1248
|
+
readFlag: createRegistryMergeFlagReader({ env, refreshAheadMs: MERGE_FLAG_REFRESH_AHEAD_MS }),
|
|
1249
1249
|
onRefresh: () => stateWriter.refresh(),
|
|
1250
1250
|
log,
|
|
1251
1251
|
});
|
|
@@ -70,6 +70,8 @@ export interface ReleaseCanary {
|
|
|
70
70
|
schema: typeof RELEASE_CANARY_SCHEMA;
|
|
71
71
|
/** The CLI release the file was made for. */
|
|
72
72
|
cliVersion: string;
|
|
73
|
+
/** Optional SHA-256 of the hook-engine source inputs when the canary ran. */
|
|
74
|
+
engineSourceSha256?: string;
|
|
73
75
|
hosts: Partial<Record<CanaryHost, ReleaseCanaryRun[]>>;
|
|
74
76
|
}
|
|
75
77
|
/** The release canary file inside this CLI's own package. */
|
|
@@ -142,6 +142,25 @@ function short(hash) {
|
|
|
142
142
|
export const RELEASE_CANARY_FILE = path.join('contracts', 'host-canary-release.json');
|
|
143
143
|
/** Schema of [`RELEASE_CANARY_FILE`]. */
|
|
144
144
|
export const RELEASE_CANARY_SCHEMA = 'hq.host-canary-release.v1';
|
|
145
|
+
const ENGINE_VERSION_RE = /^([^+\s]+)\+hq\.([0-9A-Za-z.-]+)\.src\.([0-9a-f]{64})$/;
|
|
146
|
+
/**
|
|
147
|
+
* True when a shipped canary run's `engineVersion` covers `expectedEngineVersion`:
|
|
148
|
+
* - always when exact strings match; or
|
|
149
|
+
* - when the shipped file carries a valid `engineSourceSha256` (opt-in
|
|
150
|
+
* source-hash-keyed canary) and both versions share the exact same crate
|
|
151
|
+
* version and 64-hex `.src.<digest>` (meaning identical hook-engine source
|
|
152
|
+
* inputs and identical build target/config, differing only in `+hq.<cli>`).
|
|
153
|
+
*/
|
|
154
|
+
function shippedRunMatchesEngine(runEngineVersion, expectedEngineVersion, release) {
|
|
155
|
+
if (runEngineVersion === expectedEngineVersion)
|
|
156
|
+
return true;
|
|
157
|
+
if (typeof release.engineSourceSha256 !== 'string' || !/^[0-9a-f]{64}$/.test(release.engineSourceSha256)) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
const runMatch = ENGINE_VERSION_RE.exec(runEngineVersion);
|
|
161
|
+
const expectedMatch = ENGINE_VERSION_RE.exec(expectedEngineVersion);
|
|
162
|
+
return Boolean(runMatch && expectedMatch && runMatch[1] === expectedMatch[1] && runMatch[3] === expectedMatch[3]);
|
|
163
|
+
}
|
|
145
164
|
/** The release canary file inside this CLI's own package. */
|
|
146
165
|
export function defaultReleaseCanaryPath() {
|
|
147
166
|
// src/lib/hook-engine and dist/lib/hook-engine both sit three levels below the package root.
|
|
@@ -200,7 +219,7 @@ export function releaseCanaryRefusal(release, expected) {
|
|
|
200
219
|
const runs = Array.isArray(listed) ? listed.filter((run) => run && typeof run === 'object') : [];
|
|
201
220
|
if (runs.length === 0)
|
|
202
221
|
return `no shipped host canary result for ${expected.host}`;
|
|
203
|
-
const same = runs.filter((run) => run.engineVersion
|
|
222
|
+
const same = runs.filter((run) => shippedRunMatchesEngine(run.engineVersion, expected.engineVersion, release) && run.gateSha256 === expected.gateSha256);
|
|
204
223
|
if (same.some((run) => run.passed !== true))
|
|
205
224
|
return `a shipped ${expected.host} canary for this hq-hook build and hq-core gate failed`;
|
|
206
225
|
let first = null;
|
|
@@ -209,7 +228,8 @@ export function releaseCanaryRefusal(release, expected) {
|
|
|
209
228
|
// bound to one exact build, so it does not age out on the user's machine.
|
|
210
229
|
// Freshness is checked when the release is published; a run dated in the
|
|
211
230
|
// future is still refused.
|
|
212
|
-
const
|
|
231
|
+
const matchedEngine = shippedRunMatchesEngine(run.engineVersion, expected.engineVersion, release);
|
|
232
|
+
const refusal = canaryRefusal({ schema: CANARY_RECORD_SCHEMA, hosts: { [expected.host]: run } }, { ...expected, engineVersion: matchedEngine ? run.engineVersion : expected.engineVersion, maxAgeMs: Number.POSITIVE_INFINITY });
|
|
213
233
|
if (refusal === null)
|
|
214
234
|
return null;
|
|
215
235
|
first ??= refusal.replace(`the last ${expected.host} canary`, `the shipped ${expected.host} canary`);
|
|
@@ -346,7 +346,7 @@ export declare function grokPreToolUseHold(root: string, shadow: boolean): strin
|
|
|
346
346
|
/**
|
|
347
347
|
* The dispatcher files the native PreToolUse master model reproduces, in its check order:
|
|
348
348
|
* crates/hq-hook/src/pre_tool_use_master.rs `DISPATCHER_PINS`. master-hook.sh is v16.0.48 (1a2439ae),
|
|
349
|
-
* v16.0.50 (774bca73), v16.0.49 (d5049d5f), v16.0.51 (443272ef) or v16.0.52 (ab46ebdf, and hq-core-staging #2152's f9a32c25, which only scopes the folder hook limit by event; v16.0.51 plus a PostToolUse-only
|
|
349
|
+
* v16.0.50 (774bca73), v16.0.49 (d5049d5f), v16.0.51 (443272ef) or v16.0.52 (ab46ebdf, and hq-core-staging #2152's f9a32c25, which only scopes the folder hook limit by event, and #2192's 0ab08d73, f9a32c25 without the unused hq-hook bridge; v16.0.51 plus a PostToolUse-only
|
|
350
350
|
* prefilter text for MCP tools), whose session-id alias record the native bind writes too; hook-adapter-core.sh is held per host below; hqd-hook-shim.sh is the released ab289ac0 or the
|
|
351
351
|
* hq-core-staging fd709b39a ee5e9fe7 or the hq-core v16.0.53 d1d7e7d0 (hq-core-staging #2024, whose new
|
|
352
352
|
* branches run only on an error answer from hqd, which the model never asks), and session-id.sh the released 2ebbc508 or the fd709b39a
|
|
@@ -2298,7 +2298,7 @@ export function grokPreToolUseHold(root, shadow) {
|
|
|
2298
2298
|
/**
|
|
2299
2299
|
* The dispatcher files the native PreToolUse master model reproduces, in its check order:
|
|
2300
2300
|
* crates/hq-hook/src/pre_tool_use_master.rs `DISPATCHER_PINS`. master-hook.sh is v16.0.48 (1a2439ae),
|
|
2301
|
-
* v16.0.50 (774bca73), v16.0.49 (d5049d5f), v16.0.51 (443272ef) or v16.0.52 (ab46ebdf, and hq-core-staging #2152's f9a32c25, which only scopes the folder hook limit by event; v16.0.51 plus a PostToolUse-only
|
|
2301
|
+
* v16.0.50 (774bca73), v16.0.49 (d5049d5f), v16.0.51 (443272ef) or v16.0.52 (ab46ebdf, and hq-core-staging #2152's f9a32c25, which only scopes the folder hook limit by event, and #2192's 0ab08d73, f9a32c25 without the unused hq-hook bridge; v16.0.51 plus a PostToolUse-only
|
|
2302
2302
|
* prefilter text for MCP tools), whose session-id alias record the native bind writes too; hook-adapter-core.sh is held per host below; hqd-hook-shim.sh is the released ab289ac0 or the
|
|
2303
2303
|
* hq-core-staging fd709b39a ee5e9fe7 or the hq-core v16.0.53 d1d7e7d0 (hq-core-staging #2024, whose new
|
|
2304
2304
|
* branches run only on an error answer from hqd, which the model never asks), and session-id.sh the released 2ebbc508 or the fd709b39a
|
|
@@ -2332,6 +2332,7 @@ export const PRE_TOOL_USE_DISPATCHER_PINS = [
|
|
|
2332
2332
|
'ab46ebdf0cc84a90dd95a54417817f9f9023b109d5b3710c472a8f5e89061592',
|
|
2333
2333
|
'f9a32c25f5984856a1bb91a7914495577e505c42a8c02831acf8faf049a9a806',
|
|
2334
2334
|
'711fb6d2ba7a3b126ddbbcc83e6f14a59178a75f4b856d8a4e64f67b586cabbd',
|
|
2335
|
+
'0ab08d73256bed402bc961cb64e35b0826c2d6125df234102c8b8bf4c1072de3',
|
|
2335
2336
|
],
|
|
2336
2337
|
},
|
|
2337
2338
|
{ relative: '.claude/hooks/turn-timing.sh', accepted: ['97c70a3251225ba9e469e41fd3fe2341cfe2936490f54571d2ca16de8e766443'] },
|
|
@@ -386,7 +386,8 @@
|
|
|
386
386
|
"1a2439aee50652c5143ccd18561a0aa84a1e94848d02c1aa1c99157f70023f29",
|
|
387
387
|
"d5049d5fb38d2b33467d493a4a136df8f6d9021c29e722df0d1e6a17d7f452ab",
|
|
388
388
|
"774bca73a2e806b4d9ad96b803525bdf25afd2265d63c9216881aa4ced403f16",
|
|
389
|
-
"f9a32c25f5984856a1bb91a7914495577e505c42a8c02831acf8faf049a9a806"
|
|
389
|
+
"f9a32c25f5984856a1bb91a7914495577e505c42a8c02831acf8faf049a9a806",
|
|
390
|
+
"0ab08d73256bed402bc961cb64e35b0826c2d6125df234102c8b8bf4c1072de3"
|
|
390
391
|
]
|
|
391
392
|
}
|
|
392
393
|
}
|
|
@@ -63,6 +63,27 @@ export interface LinkStableEngineOptions {
|
|
|
63
63
|
* downgrade ([`LinkStableEngineOptions.allowDowngrade`]).
|
|
64
64
|
*/
|
|
65
65
|
export declare function linkStableEngine(pinned: string, home: string, platform?: NodeJS.Platform, options?: LinkStableEngineOptions): string;
|
|
66
|
+
/** Result of an explicit postinstall downgrade of `<home>/.hq/bin/hq-hook/stable`. */
|
|
67
|
+
export interface StableDowngradeResult {
|
|
68
|
+
stable: string;
|
|
69
|
+
from: string;
|
|
70
|
+
to: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Move `<home>/.hq/bin/hq-hook/stable` back to `pinned` only when `stable`
|
|
74
|
+
* already exists as a link to a strictly newer engine version. Called solely
|
|
75
|
+
* from `scripts/install-hook-engine.mjs` (postinstall) so an explicit install
|
|
76
|
+
* of an older `hq-cli` version brings that version's hook engine back into use
|
|
77
|
+
* on registered hooks.
|
|
78
|
+
*
|
|
79
|
+
* Upgrades, equal versions, non-semver targets, and homes with no `stable`
|
|
80
|
+
* link are left untouched (upgrades continue to wait for the canary-gated
|
|
81
|
+
* `hq reindex`). Accidental downgrades from other callers still hit
|
|
82
|
+
* [`StableDowngradeRefused`] in [`linkStableEngine`].
|
|
83
|
+
*/
|
|
84
|
+
export declare function downgradeStableEngineOnInstall(pinned: string, home?: string, platform?: NodeJS.Platform, options?: {
|
|
85
|
+
now?: () => number;
|
|
86
|
+
}): StableDowngradeResult | null;
|
|
66
87
|
/** A real folder or file (not a link) of this user that group and others cannot write. */
|
|
67
88
|
export declare function checkOwnedEntry(entry: string, kind: 'folder' | 'file', platform: NodeJS.Platform): void;
|
|
68
89
|
/** True when the link resolves to `folder` (Windows reports junction targets in its own spelling). */
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* CLI when the pinned engine was canary-accepted on this machine.
|
|
20
20
|
*/
|
|
21
21
|
import * as fs from 'node:fs';
|
|
22
|
+
import { homedir } from 'node:os';
|
|
22
23
|
import * as path from 'node:path';
|
|
23
24
|
/** Name of the release-stable link next to the pinned engine versions. */
|
|
24
25
|
export const STABLE_LINK_NAME = 'stable';
|
|
@@ -278,6 +279,42 @@ export function linkStableEngine(pinned, home, platform = process.platform, opti
|
|
|
278
279
|
}
|
|
279
280
|
return stableEnginePath(pinned, home);
|
|
280
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* Move `<home>/.hq/bin/hq-hook/stable` back to `pinned` only when `stable`
|
|
284
|
+
* already exists as a link to a strictly newer engine version. Called solely
|
|
285
|
+
* from `scripts/install-hook-engine.mjs` (postinstall) so an explicit install
|
|
286
|
+
* of an older `hq-cli` version brings that version's hook engine back into use
|
|
287
|
+
* on registered hooks.
|
|
288
|
+
*
|
|
289
|
+
* Upgrades, equal versions, non-semver targets, and homes with no `stable`
|
|
290
|
+
* link are left untouched (upgrades continue to wait for the canary-gated
|
|
291
|
+
* `hq reindex`). Accidental downgrades from other callers still hit
|
|
292
|
+
* [`StableDowngradeRefused`] in [`linkStableEngine`].
|
|
293
|
+
*/
|
|
294
|
+
export function downgradeStableEngineOnInstall(pinned, home = homedir(), platform = process.platform, options = {}) {
|
|
295
|
+
const stable = path.join(hookEngineDir(home), STABLE_LINK_NAME);
|
|
296
|
+
let current;
|
|
297
|
+
try {
|
|
298
|
+
current = fs.lstatSync(stable);
|
|
299
|
+
}
|
|
300
|
+
catch (error) {
|
|
301
|
+
if (error.code === 'ENOENT')
|
|
302
|
+
return null;
|
|
303
|
+
throw error;
|
|
304
|
+
}
|
|
305
|
+
if (!current.isSymbolicLink())
|
|
306
|
+
return null;
|
|
307
|
+
const linked = stableLinkVersion(home);
|
|
308
|
+
const targetVersion = engineVersionOf(pinned, home);
|
|
309
|
+
if (!linked || !targetVersion)
|
|
310
|
+
return null;
|
|
311
|
+
const order = compareEngineVersions(targetVersion, linked);
|
|
312
|
+
if (order === null || order >= 0)
|
|
313
|
+
return null;
|
|
314
|
+
linkStableEngine(pinned, home, platform, { allowDowngrade: true, now: options.now });
|
|
315
|
+
appendStableHealLog(home, `explicit install moved ${stable} from ${linked} to ${targetVersion} (${pinned})`, (options.now ?? Date.now)());
|
|
316
|
+
return { stable, from: linked, to: targetVersion };
|
|
317
|
+
}
|
|
281
318
|
/** A real folder or file (not a link) of this user that group and others cannot write. */
|
|
282
319
|
export function checkOwnedEntry(entry, kind, platform) {
|
|
283
320
|
const stat = fs.lstatSync(entry);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@indigoai-us/hq-cli",
|
|
3
|
-
"version": "5.345.
|
|
3
|
+
"version": "5.345.274",
|
|
4
4
|
"description": "HQ by Indigo management CLI — modules and cloud sync",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -128,11 +128,11 @@
|
|
|
128
128
|
"*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}": "eslint --cache --no-error-on-unmatched-pattern"
|
|
129
129
|
},
|
|
130
130
|
"optionalDependencies": {
|
|
131
|
-
"@indigoai-us/hq-hook-win32-x64": "5.345.
|
|
132
|
-
"@indigoai-us/hq-hook-win32-arm64": "5.345.
|
|
133
|
-
"@indigoai-us/hq-hook-darwin-x64": "5.345.
|
|
134
|
-
"@indigoai-us/hq-hook-darwin-arm64": "5.345.
|
|
135
|
-
"@indigoai-us/hq-hook-linux-x64": "5.345.
|
|
136
|
-
"@indigoai-us/hq-hook-linux-arm64": "5.345.
|
|
131
|
+
"@indigoai-us/hq-hook-win32-x64": "5.345.274",
|
|
132
|
+
"@indigoai-us/hq-hook-win32-arm64": "5.345.274",
|
|
133
|
+
"@indigoai-us/hq-hook-darwin-x64": "5.345.274",
|
|
134
|
+
"@indigoai-us/hq-hook-darwin-arm64": "5.345.274",
|
|
135
|
+
"@indigoai-us/hq-hook-linux-x64": "5.345.274",
|
|
136
|
+
"@indigoai-us/hq-hook-linux-arm64": "5.345.274"
|
|
137
137
|
}
|
|
138
138
|
}
|
|
@@ -9,11 +9,30 @@ let repair = 'npm install -g @indigoai-us/hq-cli --allow-scripts=@indigoai-us/hq
|
|
|
9
9
|
try {
|
|
10
10
|
const resolver = await import('../dist/lib/hook-engine/resolve.js');
|
|
11
11
|
if (typeof resolver.HOOK_ENGINE_REPAIR === 'string') repair = resolver.HOOK_ENGINE_REPAIR;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
const pinned = resolver.installHookEngine();
|
|
13
|
+
if (!pinned) throw new Error('Optional platform package missing');
|
|
14
|
+
// An explicit reinstall of an older hq-cli moves an existing stable link back
|
|
15
|
+
// to this version's engine. Upgrades and equal versions still wait for the
|
|
16
|
+
// canary-gated reconcile (hq reindex).
|
|
17
|
+
let downgraded = null;
|
|
18
|
+
if (typeof pinned === 'string') {
|
|
19
|
+
try {
|
|
20
|
+
const stableLink = await import('../dist/lib/hook-engine/stable-link.js');
|
|
21
|
+
if (typeof stableLink.downgradeStableEngineOnInstall === 'function') {
|
|
22
|
+
downgraded = stableLink.downgradeStableEngineOnInstall(pinned);
|
|
23
|
+
}
|
|
24
|
+
} catch (error) {
|
|
25
|
+
if (error?.code !== 'ERR_MODULE_NOT_FOUND') throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (downgraded) {
|
|
29
|
+
console.warn(`HQ hook engine: moved ${downgraded.stable} from ${downgraded.from} to ${downgraded.to} for this explicit downgrade.`);
|
|
30
|
+
} else {
|
|
31
|
+
// The stable link core.next registrations name moves only through the gated
|
|
32
|
+
// reconcile (hq reindex), which the next hq command starts on its own.
|
|
33
|
+
const stale = typeof resolver.staleStableEngine === 'function' ? resolver.staleStableEngine() : null;
|
|
34
|
+
if (stale) console.warn(`HQ hook engine: ${stale.stable} still names the previous engine. The next hq command re-checks the new engine against the host canary gate and moves it; to do it now, run: hq reindex`);
|
|
35
|
+
}
|
|
17
36
|
} catch (error) {
|
|
18
37
|
console.warn(`HQ native hook engine unavailable: ${error instanceof Error ? error.message : String(error)}. Existing bash hooks remain active. Repair: ${repair}`);
|
|
19
38
|
}
|