@indigoai-us/hq-cli 5.345.269 → 5.345.272
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 +81 -0
- package/contracts/host-canary-release.json +7 -7
- package/dist/command-catalog.generated.d.ts +2 -2
- package/dist/command-catalog.generated.js +2 -2
- package/dist/commands/core-checkpoint-stop-gate-native.js +2 -13
- package/dist/commands/core-session-journal-native.js +20 -4
- package/dist/commands/signals-run.d.ts +4 -1
- package/dist/commands/signals-run.js +6 -8
- package/dist/commands/sync-core.js +2 -1
- package/dist/lib/daemon/daemon-restart.d.ts +70 -0
- package/dist/lib/daemon/daemon-restart.js +114 -0
- package/dist/lib/daemon/hook-requests-work-mesh-shims.d.ts +41 -0
- package/dist/lib/daemon/hook-requests-work-mesh-shims.js +237 -0
- package/dist/lib/daemon/hook-requests.d.ts +4 -1
- package/dist/lib/daemon/hook-requests.js +23 -1
- package/dist/lib/daemon/hq-child-bootstrap.mjs +1 -0
- package/dist/lib/daemon/installed-cli-restart.js +14 -4
- package/dist/lib/daemon/run.d.ts +1 -1
- package/dist/lib/daemon/run.js +65 -51
- package/dist/lib/daemon/supervisor.js +0 -2
- package/dist/lib/hook-engine/coverage.d.ts +21 -0
- package/dist/lib/hook-engine/coverage.js +98 -5
- package/dist/lib/hook-engine/native-precompact-compatibility.json +1 -0
- package/dist/lib/hook-engine/native-stop-compatibility.json +4 -2
- package/dist/lib/hook-engine/reconcile.js +8 -0
- package/dist/lib/hook-engine/stable-heal.d.ts +17 -1
- package/dist/lib/hook-engine/stable-heal.js +42 -5
- package/dist/lib/hook-engine/stable-link.d.ts +70 -0
- package/dist/lib/hook-engine/stable-link.js +300 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +10 -2
- package/dist/lib/hot-channels/signals-pass.js +13 -3
- package/dist/lib/install/hook-target.js +4 -1
- package/dist/lib/signals/engine.d.ts +0 -2
- package/dist/lib/signals/engine.js +12 -7
- package/dist/lib/signals/reply.js +35 -82
- package/dist/lib/signals/run-lock.d.ts +8 -0
- package/dist/lib/signals/run-lock.js +42 -7
- package/dist/lib/signals/run-record.js +2 -1
- package/dist/lib/signals/settings.d.ts +9 -4
- package/dist/lib/signals/settings.js +7 -5
- package/dist/lib/signals/steps/extract.d.ts +64 -17
- package/dist/lib/signals/steps/extract.js +175 -197
- package/dist/lib/signals/steps/types.d.ts +3 -2
- package/dist/lib/sync-core/reconcile.d.ts +7 -1
- package/dist/lib/sync-core/reconcile.js +105 -18
- package/dist/lib/sync-core/release.d.ts +52 -2
- package/dist/lib/sync-core/release.js +172 -11
- package/dist/lib/sync-core/rollout-state.d.ts +11 -0
- package/dist/lib/sync-core/rollout-state.js +16 -0
- package/dist/utils/client-health-contract.d.ts +32 -0
- package/dist/utils/client-health-contract.js +35 -0
- package/dist/utils/client-health.d.ts +43 -0
- package/dist/utils/client-health.js +106 -3
- package/dist/utils/hook-trust.js +7 -1
- package/dist/utils/host-registration.d.ts +12 -35
- package/dist/utils/host-registration.js +47 -177
- package/dist/utils/login-browser.d.ts +1 -0
- package/dist/utils/login-browser.js +31 -6
- package/dist/utils/spawn-detached-hidden.d.ts +66 -0
- package/dist/utils/spawn-detached-hidden.js +222 -0
- package/package.json +7 -7
|
@@ -1815,6 +1815,11 @@ export function uncoveredHooks(root, host, event, covers, env = process.env) {
|
|
|
1815
1815
|
if (hold)
|
|
1816
1816
|
missing.push(`(native SessionStart compatibility: ${hold})`);
|
|
1817
1817
|
}
|
|
1818
|
+
if (event === 'SessionStart' || event === 'UserPromptSubmit' || event === 'SessionEnd') {
|
|
1819
|
+
const hold = workMeshShimsHold(root, event, covered);
|
|
1820
|
+
if (hold)
|
|
1821
|
+
missing.push(`(native ${event} compatibility: ${hold})`);
|
|
1822
|
+
}
|
|
1818
1823
|
if (host === 'fleet-local' && event === 'PreToolUse' && covered.includes('fleet-local-adapter:PreToolUse')) {
|
|
1819
1824
|
const hold = fleetLocalPreToolUseHold(root);
|
|
1820
1825
|
if (hold)
|
|
@@ -1921,7 +1926,7 @@ export const SESSION_START_PINS = [
|
|
|
1921
1926
|
['core/scripts/hqd-hook-flag-cache-lib.sh', ['061d264460408e9eaf43fdf0fdde662c906a9a7dacb4e7a591e684bca28c138a']],
|
|
1922
1927
|
['core/scripts/hq-session.sh', ['db701162f71b53fd2188974d2f46c58250593dde1252d65b36e6d02b9a765fe7', '02a37c5dbf4fb5af27cc64d0f271121e990758b757a479f60e9ce099f4d65ded', 'd4d4aef60ff8b095e3abcc817598f376d3c2de8d59758c3ed6dd40d4aa4b11fb']],
|
|
1923
1928
|
['core/scripts/lib/session-id.sh', ['2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d', 'd6a04155571ec53edd853878cebaba5a5bab93801a73e356499440c1cd009c71']],
|
|
1924
|
-
['core/scripts/lib/session-scope-capability.sh', ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead', '498ffa6e4342c79eecb0c1fddec56ba03e169bb627b2da8f8ef2f09f55954b38']],
|
|
1929
|
+
['core/scripts/lib/session-scope-capability.sh', ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead', '498ffa6e4342c79eecb0c1fddec56ba03e169bb627b2da8f8ef2f09f55954b38', 'cceddf40b3ec932cc4c83b31d72d9462f5a09be32246d57299591f4b75bdcd5a']],
|
|
1925
1930
|
['core/scripts/resolve-company.sh', ['00d6fa069f574a86087c77daa44887a2617446d4300d5daebecc9bfb5d81abe7']],
|
|
1926
1931
|
];
|
|
1927
1932
|
/**
|
|
@@ -1947,6 +1952,94 @@ export function sessionStartHold(root) {
|
|
|
1947
1952
|
}
|
|
1948
1953
|
return null;
|
|
1949
1954
|
}
|
|
1955
|
+
const WORK_MESH_REGISTER_BODY_PIN = {
|
|
1956
|
+
relative: 'core/hooks/work-mesh-register.sh',
|
|
1957
|
+
accepted: [
|
|
1958
|
+
'e02a0f24da2bc094c0ee78ee68b8f35659e30f62e38bf386f2f833f94d580e57',
|
|
1959
|
+
'5cbc16337f2e8dbd0f2c5322edc2be654d8c24887ccb435ad4e22a538483d685',
|
|
1960
|
+
],
|
|
1961
|
+
missing: 'allowed',
|
|
1962
|
+
};
|
|
1963
|
+
const WORK_MESH_CLOSE_BODY_PIN = {
|
|
1964
|
+
relative: 'core/hooks/work-mesh-close.sh',
|
|
1965
|
+
accepted: [
|
|
1966
|
+
'8203c5f18b296a392d843ba259e081de6b854932abb215e30cd068ed3c17c898',
|
|
1967
|
+
'f8a3b57b0df638968a1750d1c98dccdb9f37106a7027dfd8aebf4ae5243e4456',
|
|
1968
|
+
],
|
|
1969
|
+
missing: 'allowed',
|
|
1970
|
+
};
|
|
1971
|
+
const WORK_MESH_GROUND_BODY_PIN = {
|
|
1972
|
+
relative: 'core/hooks/work-mesh-ground.sh',
|
|
1973
|
+
accepted: [
|
|
1974
|
+
'22000e66f7f133f8ccda9556d53f61b6c861caf4169f78f142cd70d5e034eae0',
|
|
1975
|
+
'eb4ab208156399da64d925564b87191d3685d3ede4925e6b7f4e41467fdcd645',
|
|
1976
|
+
],
|
|
1977
|
+
missing: 'allowed',
|
|
1978
|
+
};
|
|
1979
|
+
export const WORK_MESH_SESSION_START_PINS = [
|
|
1980
|
+
{
|
|
1981
|
+
shim: {
|
|
1982
|
+
relative: 'core/hooks/SessionStart/35-work-mesh-register.sh',
|
|
1983
|
+
accepted: ['89f53b15099c7b01de6c5eeb35a7d40aa5075e8c4ac8cf9a6e511799cb3b57b9'],
|
|
1984
|
+
},
|
|
1985
|
+
body: WORK_MESH_REGISTER_BODY_PIN,
|
|
1986
|
+
},
|
|
1987
|
+
{
|
|
1988
|
+
shim: {
|
|
1989
|
+
relative: 'core/hooks/SessionStart/36-work-mesh-sweep.sh',
|
|
1990
|
+
accepted: ['870931f665f97cfa957806c2ba5466eb3ee2922a32c3c331a7c6fe447b60fc56'],
|
|
1991
|
+
},
|
|
1992
|
+
body: WORK_MESH_CLOSE_BODY_PIN,
|
|
1993
|
+
},
|
|
1994
|
+
];
|
|
1995
|
+
export const WORK_MESH_USER_PROMPT_SUBMIT_PINS = [
|
|
1996
|
+
{
|
|
1997
|
+
shim: {
|
|
1998
|
+
relative: 'core/hooks/UserPromptSubmit/35-work-mesh-register.sh',
|
|
1999
|
+
accepted: ['89f53b15099c7b01de6c5eeb35a7d40aa5075e8c4ac8cf9a6e511799cb3b57b9'],
|
|
2000
|
+
},
|
|
2001
|
+
body: WORK_MESH_REGISTER_BODY_PIN,
|
|
2002
|
+
},
|
|
2003
|
+
{
|
|
2004
|
+
shim: {
|
|
2005
|
+
relative: 'core/hooks/UserPromptSubmit/70-work-mesh-ground.sh',
|
|
2006
|
+
accepted: ['d07328e4e5d8d3572e91321d209bf4c712317b1c6616ddd9084d3e544baa2e88'],
|
|
2007
|
+
},
|
|
2008
|
+
body: WORK_MESH_GROUND_BODY_PIN,
|
|
2009
|
+
},
|
|
2010
|
+
];
|
|
2011
|
+
export const WORK_MESH_SESSION_END_PINS = [
|
|
2012
|
+
{
|
|
2013
|
+
shim: {
|
|
2014
|
+
relative: 'core/hooks/SessionEnd/35-work-mesh-close.sh',
|
|
2015
|
+
accepted: ['878d8e77bf67f3ad0cb9754ff625a001083213751ef2832c6071288e0b9f5bbe'],
|
|
2016
|
+
},
|
|
2017
|
+
body: WORK_MESH_CLOSE_BODY_PIN,
|
|
2018
|
+
},
|
|
2019
|
+
];
|
|
2020
|
+
/**
|
|
2021
|
+
* Why `event` (`SessionStart`, `UserPromptSubmit`, or `SessionEnd`) must stay on the shell
|
|
2022
|
+
* registration for a present legacy Work Mesh shim in `root`: the shim file exists on disk, is
|
|
2023
|
+
* claimed in `covered`, and either the shim or its `core/hooks/work-mesh-*.sh` body is not a
|
|
2024
|
+
* pinned revision (`pinnedFilesHold`). Missing shims are not held.
|
|
2025
|
+
*/
|
|
2026
|
+
export function workMeshShimsHold(root, event, covered) {
|
|
2027
|
+
const entries = event === 'SessionStart'
|
|
2028
|
+
? WORK_MESH_SESSION_START_PINS
|
|
2029
|
+
: event === 'UserPromptSubmit'
|
|
2030
|
+
? WORK_MESH_USER_PROMPT_SUBMIT_PINS
|
|
2031
|
+
: WORK_MESH_SESSION_END_PINS;
|
|
2032
|
+
for (const entry of entries) {
|
|
2033
|
+
if (!covered.includes(entry.shim.relative))
|
|
2034
|
+
continue;
|
|
2035
|
+
if (!regularFile(path.join(root, entry.shim.relative)))
|
|
2036
|
+
continue;
|
|
2037
|
+
const hold = pinnedFilesHold(root, event, [entry.shim, entry.body]);
|
|
2038
|
+
if (hold)
|
|
2039
|
+
return hold;
|
|
2040
|
+
}
|
|
2041
|
+
return null;
|
|
2042
|
+
}
|
|
1950
2043
|
/**
|
|
1951
2044
|
* The script revisions the native SessionStart `migrate-policy-triggers` port rebuilds
|
|
1952
2045
|
* (`crates/hq-hook/src/session_start_ss1/migrate_triggers.rs`: `SCRIPT_SHA256`,
|
|
@@ -2023,7 +2116,7 @@ export const FLEET_LOCAL_PRE_TOOL_USE_PINS = [
|
|
|
2023
2116
|
],
|
|
2024
2117
|
missing: 'allowed',
|
|
2025
2118
|
},
|
|
2026
|
-
{ relative: 'core/scripts/lib/session-scope-capability.sh', accepted: ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead', '498ffa6e4342c79eecb0c1fddec56ba03e169bb627b2da8f8ef2f09f55954b38'], missing: 'allowed' },
|
|
2119
|
+
{ relative: 'core/scripts/lib/session-scope-capability.sh', accepted: ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead', '498ffa6e4342c79eecb0c1fddec56ba03e169bb627b2da8f8ef2f09f55954b38', 'cceddf40b3ec932cc4c83b31d72d9462f5a09be32246d57299591f4b75bdcd5a'], missing: 'allowed' },
|
|
2027
2120
|
];
|
|
2028
2121
|
/**
|
|
2029
2122
|
* Why fleet-local PreToolUse must stay on the shell adapter in `root`: a present file of
|
|
@@ -2263,7 +2356,7 @@ export const PRE_TOOL_USE_DISPATCHER_PINS = [
|
|
|
2263
2356
|
{ relative: 'core/scripts/lib/epochrealtime.sh', accepted: ['4c9205520dba31533c95eea145f6068ba626885c342c2aa1f232a7237d046cdf'] },
|
|
2264
2357
|
{ relative: 'core/scripts/lib/perl-child-locale.sh', accepted: ['18e6b9d0e22874eea00ecc868b4dcfebbc3bb42434d8d0c81b20baec1194df2e'] },
|
|
2265
2358
|
{ relative: 'core/scripts/lib/session-id.sh', accepted: ['2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d', 'd6a04155571ec53edd853878cebaba5a5bab93801a73e356499440c1cd009c71'] },
|
|
2266
|
-
{ relative: 'core/scripts/lib/session-scope-capability.sh', accepted: ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead', '498ffa6e4342c79eecb0c1fddec56ba03e169bb627b2da8f8ef2f09f55954b38'] },
|
|
2359
|
+
{ relative: 'core/scripts/lib/session-scope-capability.sh', accepted: ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead', '498ffa6e4342c79eecb0c1fddec56ba03e169bb627b2da8f8ef2f09f55954b38', 'cceddf40b3ec932cc4c83b31d72d9462f5a09be32246d57299591f4b75bdcd5a'] },
|
|
2267
2360
|
{ relative: 'core/scripts/resolve-hq-root.sh', accepted: ['188e99c7c60bc9909290a666d6f3b93387ae6cf68f2eeb41fd24c2dea62a5240'] },
|
|
2268
2361
|
];
|
|
2269
2362
|
/**
|
|
@@ -2684,7 +2777,7 @@ export const PROMPT_COMPANY_BIND_PINS = [
|
|
|
2684
2777
|
},
|
|
2685
2778
|
{ relative: 'core/scripts/hq-session.sh', accepted: ['db701162f71b53fd2188974d2f46c58250593dde1252d65b36e6d02b9a765fe7', '02a37c5dbf4fb5af27cc64d0f271121e990758b757a479f60e9ce099f4d65ded', 'd4d4aef60ff8b095e3abcc817598f376d3c2de8d59758c3ed6dd40d4aa4b11fb'] },
|
|
2686
2779
|
{ relative: 'core/scripts/lib/session-id.sh', accepted: ['2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d', 'd6a04155571ec53edd853878cebaba5a5bab93801a73e356499440c1cd009c71'] },
|
|
2687
|
-
{ relative: 'core/scripts/lib/session-scope-capability.sh', accepted: ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead', '498ffa6e4342c79eecb0c1fddec56ba03e169bb627b2da8f8ef2f09f55954b38'] },
|
|
2780
|
+
{ relative: 'core/scripts/lib/session-scope-capability.sh', accepted: ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead', '498ffa6e4342c79eecb0c1fddec56ba03e169bb627b2da8f8ef2f09f55954b38', 'cceddf40b3ec932cc4c83b31d72d9462f5a09be32246d57299591f4b75bdcd5a'] },
|
|
2688
2781
|
];
|
|
2689
2782
|
/**
|
|
2690
2783
|
* Why UserPromptSubmit must stay on the shell registration in `root`: the native
|
|
@@ -2787,7 +2880,7 @@ export function postToolUseAdapterHold(root, host) {
|
|
|
2787
2880
|
return null;
|
|
2788
2881
|
}
|
|
2789
2882
|
/** The session-scope-capability.sh master-hook's Task-agent pin is modelled on (crates/hq-hook/src/scope/session.rs `SUBAGENT_PIN_LIB_SHA256`). */
|
|
2790
|
-
export const SUBAGENT_SCOPE_LIBRARY = { relative: 'core/scripts/lib/session-scope-capability.sh', accepted: ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead', '498ffa6e4342c79eecb0c1fddec56ba03e169bb627b2da8f8ef2f09f55954b38'] };
|
|
2883
|
+
export const SUBAGENT_SCOPE_LIBRARY = { relative: 'core/scripts/lib/session-scope-capability.sh', accepted: ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead', '498ffa6e4342c79eecb0c1fddec56ba03e169bb627b2da8f8ef2f09f55954b38', 'cceddf40b3ec932cc4c83b31d72d9462f5a09be32246d57299591f4b75bdcd5a'] };
|
|
2791
2884
|
/**
|
|
2792
2885
|
* Why SubagentStart or SubagentStop (`event`) must stay on the shell registration in `root`: the
|
|
2793
2886
|
* native master work (crates/hq-hook/src/lifecycle_master.rs `begin`) refuses every such event that
|
|
@@ -310,6 +310,7 @@
|
|
|
310
310
|
"3194d664e3840dcbf48a2d5681feb7cd299bd6f60d296337c70d8042d60886c2",
|
|
311
311
|
"388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead",
|
|
312
312
|
"498ffa6e4342c79eecb0c1fddec56ba03e169bb627b2da8f8ef2f09f55954b38",
|
|
313
|
+
"cceddf40b3ec932cc4c83b31d72d9462f5a09be32246d57299591f4b75bdcd5a",
|
|
313
314
|
"5d4c619a55db0de6ff210a3aa0e99aa92fb5795a3290dcfcafc141e3ad3894b6",
|
|
314
315
|
"743d9438922f0bcc29f09b38f159b4fd686cc2ba15390602ef7b7f1d8db9ac26",
|
|
315
316
|
"9ea044084200e5f2d1f47477ffeaf591a87b406e9bf48c8fd6e24c551c799fc1",
|
|
@@ -197,7 +197,8 @@
|
|
|
197
197
|
],
|
|
198
198
|
"core/scripts/lib/session-scope-capability.sh": [
|
|
199
199
|
"388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead",
|
|
200
|
-
"498ffa6e4342c79eecb0c1fddec56ba03e169bb627b2da8f8ef2f09f55954b38"
|
|
200
|
+
"498ffa6e4342c79eecb0c1fddec56ba03e169bb627b2da8f8ef2f09f55954b38",
|
|
201
|
+
"cceddf40b3ec932cc4c83b31d72d9462f5a09be32246d57299591f4b75bdcd5a"
|
|
201
202
|
],
|
|
202
203
|
"core/scripts/lib/transcript-tail.sh": [
|
|
203
204
|
"73eadafdd8e7c375bd12383947ac73c43e7dfe79b29e6553da1cb5b2746bb217"
|
|
@@ -384,7 +385,8 @@
|
|
|
384
385
|
".claude/hooks/master-hook.sh": [
|
|
385
386
|
"1a2439aee50652c5143ccd18561a0aa84a1e94848d02c1aa1c99157f70023f29",
|
|
386
387
|
"d5049d5fb38d2b33467d493a4a136df8f6d9021c29e722df0d1e6a17d7f452ab",
|
|
387
|
-
"774bca73a2e806b4d9ad96b803525bdf25afd2265d63c9216881aa4ced403f16"
|
|
388
|
+
"774bca73a2e806b4d9ad96b803525bdf25afd2265d63c9216881aa4ced403f16",
|
|
389
|
+
"f9a32c25f5984856a1bb91a7914495577e505c42a8c02831acf8faf049a9a806"
|
|
388
390
|
]
|
|
389
391
|
}
|
|
390
392
|
}
|
|
@@ -186,6 +186,14 @@ export function reconcileHookRegistrations(root, home = homedir(), env = process
|
|
|
186
186
|
claudeProjectNext = claudeProjectTarget(rawCoreNext, claudeNext, root, env);
|
|
187
187
|
codexNext = forHost(rawCoreNext, root, 'codex', env);
|
|
188
188
|
antigravityNext = rawCoreNext;
|
|
189
|
+
const acceptedHosts = [];
|
|
190
|
+
if (claudeNext || claudeProjectNext)
|
|
191
|
+
acceptedHosts.push('claude');
|
|
192
|
+
if (codexNext)
|
|
193
|
+
acceptedHosts.push('codex');
|
|
194
|
+
if (acceptedHosts.length > 0) {
|
|
195
|
+
getCoreNextCandidate(rawCoreNext)?.recordAccepted?.(acceptedHosts);
|
|
196
|
+
}
|
|
189
197
|
}
|
|
190
198
|
else if (rawCoreNext) {
|
|
191
199
|
const candidate = getCoreNextCandidate(rawCoreNext);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* After an update, heal the `stable` link core.next registrations name by
|
|
3
|
-
* re-running the gated reconcile
|
|
3
|
+
* re-running the gated reconcile; the heal moves the link directly only to
|
|
4
|
+
* undo a roll-back (below).
|
|
4
5
|
*
|
|
5
6
|
* `npm install -g @indigoai-us/hq-cli` pins the new engine and rewrites the
|
|
6
7
|
* `current` pointer. `stable` keeps naming the previous engine until
|
|
@@ -15,6 +16,19 @@
|
|
|
15
16
|
*
|
|
16
17
|
* The postinstall moves nothing ([`staleStableEngine`] only reports).
|
|
17
18
|
*
|
|
19
|
+
* Two cases do not wait for the reindex, so a code-complete engine never flips
|
|
20
|
+
* back:
|
|
21
|
+
* - Roll-back: `stable` names an older engine than the pinned one, and the
|
|
22
|
+
* pinned engine is recorded in the accepted-engine record
|
|
23
|
+
* ([`isAcceptedHookEngine`]): it already passed the host canary gate on this
|
|
24
|
+
* machine. Something older (an old hq-cli run with the real home) moved the
|
|
25
|
+
* link back below it. The heal relinks to the pinned engine at once, then
|
|
26
|
+
* starts the reindex as usual. A pinned engine with no acceptance record waits
|
|
27
|
+
* for the gated reindex, as after any update.
|
|
28
|
+
* - `stable` names a newer engine than this CLI pins, and its version folder is
|
|
29
|
+
* still there: an older CLI is running. The heal starts nothing, so it cannot
|
|
30
|
+
* move the link back.
|
|
31
|
+
*
|
|
18
32
|
* The roots come from the `--hq-root` arguments in the user-scope hook files,
|
|
19
33
|
* so this starts an unattended `hq reindex` in any folder named there. That is
|
|
20
34
|
* no new boundary: only someone who can already write those files (and so
|
|
@@ -60,6 +74,8 @@ export interface StableHealResult {
|
|
|
60
74
|
roots: string[];
|
|
61
75
|
/** Why no reindex was started, when stale and none was. */
|
|
62
76
|
skipped?: string;
|
|
77
|
+
/** The engine version `stable` was moved back up to before any reindex (a roll-back healed at once). */
|
|
78
|
+
relinked?: string;
|
|
63
79
|
}
|
|
64
80
|
/**
|
|
65
81
|
* The HQ roots to reconcile: each root a user-scope hook file (Claude Code,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* After an update, heal the `stable` link core.next registrations name by
|
|
3
|
-
* re-running the gated reconcile
|
|
3
|
+
* re-running the gated reconcile; the heal moves the link directly only to
|
|
4
|
+
* undo a roll-back (below).
|
|
4
5
|
*
|
|
5
6
|
* `npm install -g @indigoai-us/hq-cli` pins the new engine and rewrites the
|
|
6
7
|
* `current` pointer. `stable` keeps naming the previous engine until
|
|
@@ -15,6 +16,19 @@
|
|
|
15
16
|
*
|
|
16
17
|
* The postinstall moves nothing ([`staleStableEngine`] only reports).
|
|
17
18
|
*
|
|
19
|
+
* Two cases do not wait for the reindex, so a code-complete engine never flips
|
|
20
|
+
* back:
|
|
21
|
+
* - Roll-back: `stable` names an older engine than the pinned one, and the
|
|
22
|
+
* pinned engine is recorded in the accepted-engine record
|
|
23
|
+
* ([`isAcceptedHookEngine`]): it already passed the host canary gate on this
|
|
24
|
+
* machine. Something older (an old hq-cli run with the real home) moved the
|
|
25
|
+
* link back below it. The heal relinks to the pinned engine at once, then
|
|
26
|
+
* starts the reindex as usual. A pinned engine with no acceptance record waits
|
|
27
|
+
* for the gated reindex, as after any update.
|
|
28
|
+
* - `stable` names a newer engine than this CLI pins, and its version folder is
|
|
29
|
+
* still there: an older CLI is running. The heal starts nothing, so it cannot
|
|
30
|
+
* move the link back.
|
|
31
|
+
*
|
|
18
32
|
* The roots come from the `--hq-root` arguments in the user-scope hook files,
|
|
19
33
|
* so this starts an unattended `hq reindex` in any folder named there. That is
|
|
20
34
|
* no new boundary: only someone who can already write those files (and so
|
|
@@ -32,6 +46,7 @@ import * as path from 'node:path';
|
|
|
32
46
|
import { CORE_NEXT_LINK, hqRootArgument, userHookSettingsFile } from './registration-identity.js';
|
|
33
47
|
import { staleStableEngine } from './resolve.js';
|
|
34
48
|
import { resolveDefaultHqRoot } from '../../utils/hq-root-resolver.js';
|
|
49
|
+
import { appendStableHealLog, compareEngineVersions, engineVersionOf, isAcceptedHookEngine, linkStableEngine, stableLinkVersion } from './stable-link.js';
|
|
35
50
|
/** Set in the reindex the heal starts, so that process does not start another. */
|
|
36
51
|
export const STABLE_HEAL_ENV = 'HQ_STABLE_HEAL';
|
|
37
52
|
/**
|
|
@@ -175,16 +190,38 @@ export function healStableEngine(options = {}) {
|
|
|
175
190
|
if (!stale)
|
|
176
191
|
return { stale: null, roots: [] };
|
|
177
192
|
const now = (options.now ?? Date.now)();
|
|
193
|
+
const linked = stableLinkVersion(home);
|
|
194
|
+
const pinnedVersion = engineVersionOf(stale.pinned, home);
|
|
195
|
+
const order = linked && pinnedVersion ? compareEngineVersions(linked, pinnedVersion) : null;
|
|
196
|
+
if (order !== null && order > 0 && stale.resolved !== null) {
|
|
197
|
+
// No log line here: an older CLI reaches this on every command.
|
|
198
|
+
return { stale, roots: [], skipped: 'stable names a newer engine than this CLI pins' };
|
|
199
|
+
}
|
|
200
|
+
let relinked;
|
|
201
|
+
if (order !== null && order < 0 && isAcceptedHookEngine(home, stale.pinned, platform)) {
|
|
202
|
+
// The pinned engine already passed the host canary gate here (commitStable
|
|
203
|
+
// recorded it), so the link was rolled back below an accepted engine:
|
|
204
|
+
// relink now, not after the reindex.
|
|
205
|
+
try {
|
|
206
|
+
linkStableEngine(stale.pinned, home, platform, { now: () => now });
|
|
207
|
+
relinked = pinnedVersion;
|
|
208
|
+
appendStableHealLog(home, `stable rolled back to ${linked}; relinked to the canary-accepted pinned engine ${stale.pinned} before the reindex`, now);
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
appendStableHealLog(home, `stable rolled back to ${linked}; relink to ${stale.pinned} failed: ${error instanceof Error ? error.message : String(error)}`, now);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const extra = relinked ? { relinked } : {};
|
|
178
215
|
const last = readState(home);
|
|
179
216
|
if (last && last.pinned === stale.pinned && typeof last.at === 'number' && now - last.at >= 0 && now - last.at < STABLE_HEAL_RETRY_MS) {
|
|
180
|
-
return { stale, roots: [], skipped: 'a heal for this engine started less than an hour ago' };
|
|
217
|
+
return { stale, roots: [], skipped: 'a heal for this engine started less than an hour ago', ...extra };
|
|
181
218
|
}
|
|
182
219
|
const roots = stableHealRoots(home, env, options.cwd ?? process.cwd(), platform);
|
|
183
220
|
if (!roots.length)
|
|
184
|
-
return { stale, roots: [], skipped: 'no HQ root to reconcile' };
|
|
221
|
+
return { stale, roots: [], skipped: 'no HQ root to reconcile', ...extra };
|
|
185
222
|
const cliEntry = options.cliEntry ?? process.argv[1];
|
|
186
223
|
if (!cliEntry)
|
|
187
|
-
return { stale, roots: [], skipped: 'no CLI entry to run' };
|
|
224
|
+
return { stale, roots: [], skipped: 'no CLI entry to run', ...extra };
|
|
188
225
|
writeState(home, stale.pinned, now);
|
|
189
226
|
const childEnv = { ...env, [STABLE_HEAL_ENV]: '1', HQ_INSTALL_FOLLOWUP: '1' };
|
|
190
227
|
for (const name of GATE_WEAKENING_ENV)
|
|
@@ -209,6 +246,6 @@ export function healStableEngine(options = {}) {
|
|
|
209
246
|
finally {
|
|
210
247
|
fs.closeSync(log);
|
|
211
248
|
}
|
|
212
|
-
return { stale, roots };
|
|
249
|
+
return { stale, roots, ...extra };
|
|
213
250
|
}
|
|
214
251
|
//# sourceMappingURL=stable-heal.js.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** Name of the release-stable link next to the pinned engine versions. */
|
|
2
|
+
export declare const STABLE_LINK_NAME = "stable";
|
|
3
|
+
/** Record of canary-accepted hook engines committed to `stable`, under the home folder. */
|
|
4
|
+
export declare const ACCEPTED_HOOK_ENGINE_RECORD: string;
|
|
5
|
+
/** Schema of [`ACCEPTED_HOOK_ENGINE_RECORD`]. */
|
|
6
|
+
export declare const ACCEPTED_HOOK_ENGINE_SCHEMA = "hq.accepted-hook-engine.v1";
|
|
7
|
+
export type CoreNextHost = 'claude' | 'codex' | 'grok' | 'fleet-local' | 'agents-v2' | 'antigravity';
|
|
8
|
+
/** One canary-accepted engine recorded when `commitStable` moved `stable` to it. */
|
|
9
|
+
export interface AcceptedHookEngineEntry {
|
|
10
|
+
engineVersion: string;
|
|
11
|
+
pinnedEngine: string;
|
|
12
|
+
acceptedAt: string;
|
|
13
|
+
hosts: CoreNextHost[];
|
|
14
|
+
}
|
|
15
|
+
export interface AcceptedHookEngineRecord {
|
|
16
|
+
schema: typeof ACCEPTED_HOOK_ENGINE_SCHEMA;
|
|
17
|
+
engines: Record<string, AcceptedHookEngineEntry>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Read `<home>/.hq/bin/hq-hook/accepted-engine.json`; null when absent,
|
|
21
|
+
* unreadable, invalid, or writable by another user.
|
|
22
|
+
*/
|
|
23
|
+
export declare function readAcceptedHookEngineRecord(home: string, platform?: NodeJS.Platform): AcceptedHookEngineRecord | null;
|
|
24
|
+
/** True when `pinned` resolves to an engine recorded in the accepted-engine record (it passed the host canary gate here). */
|
|
25
|
+
export declare function isAcceptedHookEngine(home: string, pinned: string, platform?: NodeJS.Platform): boolean;
|
|
26
|
+
/** Thrown when `stable` names a newer, runnable engine and the caller did not ask for a downgrade. */
|
|
27
|
+
export declare class StableDowngradeRefused extends Error {
|
|
28
|
+
constructor(message: string);
|
|
29
|
+
}
|
|
30
|
+
export declare function hookEngineDir(home: string): string;
|
|
31
|
+
/** The stable path that stands for a pinned engine path. */
|
|
32
|
+
export declare function stableEnginePath(pinned: string, home: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Semver precedence of two engine version folder names: negative when `a` is
|
|
35
|
+
* older, positive when newer, 0 when equal. Null when either is not a version
|
|
36
|
+
* folder name, so the caller cannot tell which is older.
|
|
37
|
+
*/
|
|
38
|
+
export declare function compareEngineVersions(a: string, b: string): number | null;
|
|
39
|
+
/** The version folder an engine path under `<home>/.hq/bin/hq-hook` sits in; null when it is not under it. */
|
|
40
|
+
export declare function engineVersionOf(pinned: string, home: string): string | null;
|
|
41
|
+
/** The version folder name `stable` names (even when that folder is gone); null when it is not a link. */
|
|
42
|
+
export declare function stableLinkVersion(home: string): string | null;
|
|
43
|
+
/** Append one line to `<home>/.hq/logs/stable-heal.log`; best effort. */
|
|
44
|
+
export declare function appendStableHealLog(home: string, line: string, now?: number): void;
|
|
45
|
+
export interface LinkStableEngineOptions {
|
|
46
|
+
/**
|
|
47
|
+
* The person asked to move `stable` to an older engine (a repair or a
|
|
48
|
+
* downgrade they requested). Only such a command passes true.
|
|
49
|
+
*/
|
|
50
|
+
allowDowngrade?: boolean;
|
|
51
|
+
now?: () => number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Point `<home>/.hq/bin/hq-hook/stable` at the pinned engine's version folder
|
|
55
|
+
* and return the stable engine path. The link is replaced by rename, so a
|
|
56
|
+
* planted file at the temporary name or the link itself is never followed. A
|
|
57
|
+
* `stable` that is a real folder (not a link) is someone else's and is left
|
|
58
|
+
* alone: the call fails and the caller keeps the current registrations.
|
|
59
|
+
*
|
|
60
|
+
* A link that names a newer engine than `pinned`, which is still there and
|
|
61
|
+
* runnable, stays where it is: the call records the refusal in stable-heal.log
|
|
62
|
+
* and throws [`StableDowngradeRefused`], unless the person asked for the
|
|
63
|
+
* downgrade ([`LinkStableEngineOptions.allowDowngrade`]).
|
|
64
|
+
*/
|
|
65
|
+
export declare function linkStableEngine(pinned: string, home: string, platform?: NodeJS.Platform, options?: LinkStableEngineOptions): string;
|
|
66
|
+
/** A real folder or file (not a link) of this user that group and others cannot write. */
|
|
67
|
+
export declare function checkOwnedEntry(entry: string, kind: 'folder' | 'file', platform: NodeJS.Platform): void;
|
|
68
|
+
/** True when the link resolves to `folder` (Windows reports junction targets in its own spelling). */
|
|
69
|
+
export declare function pointsAt(link: string, folder: string): boolean;
|
|
70
|
+
//# sourceMappingURL=stable-link.d.ts.map
|