@indigoai-us/hq-cli 5.345.258 → 5.345.261
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 +58 -0
- package/assets/scaffold/core/scripts/handoff-knowledge-commit.sh +163 -5
- package/assets/scaffold/core/scripts/handoff-post.sh +30 -0
- package/assets/scaffold/core/scripts/handoff-sync-prefetch.sh +39 -0
- package/assets/scaffold/core/scripts/handoff-sync-publish.sh +51 -3
- package/contracts/host-canary-release.json +7 -7
- package/dist/commands/cloud.d.ts +2 -7
- package/dist/commands/cloud.js +2 -29
- package/dist/commands/core-bucket-c-handoff-knowledge-native.d.ts +24 -2
- package/dist/commands/core-bucket-c-handoff-knowledge-native.js +170 -19
- package/dist/commands/core-bucket-c-handoff-sync-native.d.ts +4 -2
- package/dist/commands/core-bucket-c-handoff-sync-native.js +153 -34
- package/dist/commands/core-bucket-c-handoff-sync-worker.cjs +201 -0
- package/dist/commands/core-delegate-w1b.js +17 -16
- package/dist/commands/core-delegate.js +5 -4
- package/dist/commands/core-handoff.d.ts +10 -0
- package/dist/commands/core-handoff.js +138 -16
- package/dist/commands/reindex.d.ts +3 -0
- package/dist/commands/reindex.js +11 -5
- package/dist/commands/rescue.js +7 -2
- package/dist/commands/sync-core.js +24 -7
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +3227 -2138
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lib/canonical-person.d.ts +19 -0
- package/dist/lib/canonical-person.js +30 -0
- package/dist/lib/company-sessions-cli.d.ts +12 -0
- package/dist/lib/company-sessions-cli.js +54 -0
- package/dist/lib/company-sessions.d.ts +31 -0
- package/dist/lib/company-sessions.js +304 -0
- package/dist/lib/doctor/fix/process-identity.d.ts +13 -0
- package/dist/lib/doctor/fix/process-identity.js +63 -7
- package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.js +1 -1
- package/dist/lib/hook-engine/coverage.d.ts +44 -1
- package/dist/lib/hook-engine/coverage.js +129 -1
- package/dist/lib/onboarding/orchestrator.js +4 -2
- package/dist/lib/sync-core/engine-home.d.ts +5 -1
- package/dist/lib/sync-core/engine-home.js +6 -2
- package/dist/lib/sync-core/reconcile.d.ts +5 -0
- package/dist/lib/sync-core/reconcile.js +21 -1
- package/dist/lib/sync-core/vault-uid.d.ts +2 -0
- package/dist/lib/sync-core/vault-uid.js +4 -0
- package/dist/utils/delegate-lock.d.ts +18 -0
- package/dist/utils/delegate-lock.js +149 -37
- package/dist/utils/sync-operation-lock.d.ts +2 -1
- package/dist/utils/sync-operation-lock.js +13 -2
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,64 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [5.345.261] — 2026-11-26
|
|
6
|
+
- Internal: the hq-hook PR test shards, the Grok comparison and the Windows Clippy cross-check run on the autoscaled AWS arm64 pool (`hq-cli-main-priority`) instead of waiting in the fixed `hq-hook-mac` queue, and no longer wait for the Mac route job. `HQ_HOOK_AWS_OVERFLOW=off` puts them back on `hq-hook-mac`; `HQ_HOOK_AWS_SHARDS` is no longer read. The shards install rustfmt with clippy, so the round12 formatter fixture in `credential_grep_sources` can run `cargo fmt` on a fresh runner. Only pull request and train runs cancel a superseded run; the daily schedule never does.
|
|
7
|
+
- Internal: the Windows hq-hook test step in `hq-hook.yml` now runs under `shell: bash` (Git Bash), matching `hq-hook-windows-baseline.yml`, and all three Windows hq-hook workflows verify `awk` is on `PATH` before running tests (CI-only).
|
|
8
|
+
- On hq-agents-v2 bots running the Rust hook engine, the current hq-agents-v2 main hook adapter and the adapter from hq-agents-v2 #364 (JSON deny on `pre_tool_call`) are now known revisions. A tool call under either goes to the adapter instead of being refused natively, so these bots no longer block every tool call after the adapter update. Under the main adapter, SessionEnd, PostToolUse, SubagentStop and SessionStart stay native as under #347; under the #364 adapter every event goes to the adapter. An edited adapter is still refused.
|
|
9
|
+
- Exclude `gtimeout` alongside `timeout` when `command_guards` builds the `no-timeout` test PATH, so macOS hosts with Homebrew coreutils exercise the missing-timeout refusal path.
|
|
10
|
+
- Accept exit code `255` alongside `128`/`129` as git's invalid-option rejection in `credential_grep_sources::grep_recurse_and_pathspec_file_do_not_leak`, matching older Apple Git on macOS for `git diff --pathspec-from-file=...`.
|
|
11
|
+
- Fixed: native delegate locking on Windows no longer spawns PowerShell to acquire, hold, or reclaim dead-process manifest locks, eliminating false "verification or delivery is active" errors when PowerShell is slow or unavailable; when a process identity probe does time out or cannot run, native delegate commands now report that probe failure separately from a held lock.
|
|
12
|
+
- Fixed: `hq-hook` vault-write locale warnings omit the trailing `: <strerror>` suffix when `newlocale` leaves `errno` at 0, matching GNU Bash across Linux and macOS hosts.
|
|
13
|
+
- Fixed quadratic scans in the Rust hook engine's native transcript and field reader (`trigger_facts::native`) that could cause `inject-policy-on-trigger` to time out on large, number-heavy Codex rollout transcripts during `PreToolUse` and `UserPromptSubmit`. `serde_json::Number` literals are now formatted directly in jq's decNumber form without rewriting inputs with textual placeholders or scanning all numbers per transcript event.
|
|
14
|
+
- Clear inherited `GIT_*` environment variables (such as `GIT_CONFIG_GLOBAL=/dev/null` on macOS native CI runners) in `after_turn_suggestions::native_stop_with` so in-process Stop parity matches the clean bash child environment.
|
|
15
|
+
- Exclude host-installed `agent-browser` from `PATH` in `agents_v2_session_start_parity` so `50-agent-browser-presence-check.sh` exercises the missing-browser nudge consistently on machines where `agent-browser` is installed.
|
|
16
|
+
- Detect macOS BSD `awk` `towc` multibyte `substr` crashes at runtime in `gate_native` so UTF-8 prompt-word tests assert the `LC_ALL=C` bash-verified native receipt instead of expecting native to fail open like BSD `awk`.
|
|
17
|
+
- Strip inherited `GIT_*` variables (such as `GIT_CONFIG_GLOBAL=/dev/null` on macOS native CI runners) in `isolated_command::isolate` and `pretool_paths::numbered_sibling_matches_bash_on_every_path_form_and_tool` so `protect-core` sees the same clean environment as bash parity runs.
|
|
18
|
+
- Exclude host-installed `hq` from the test `PATH` in `reindex_hook` so `no hq` cases behave identically on machines where `hq` is installed in `/opt/homebrew/bin` or another `PATH` directory.
|
|
19
|
+
- Use POSIX `touch -t 202001010000` in `session_start_ss1` stale-lock reclamation test so it passes on macOS BSD `touch` as well as Linux and Windows Git Bash.
|
|
20
|
+
- Measure `recorder_all_events::recording_adds_a_small_share_of_the_event_cost` full-vs-empty store overhead using per-child CPU time via `libc::wait4` instead of wall-clock time so the 10% bound stays stable under host CPU contention without widening the threshold.
|
|
21
|
+
- Use the production default `HQ_HQD_SHIM_TIMEOUT_MS` budget in `session_start_hqd_open` parity tests instead of an artificial 300 ms override that starved the pinned bash+perl shim under Mac container load.
|
|
22
|
+
- Strip Windows verbatim `\\?\` prefixes in `scope_bash` test tempdirs and format Bash command path operands in MSYS POSIX form.
|
|
23
|
+
- Fixed: on Windows, fleet-local and agents-v2 tool calls work again with every home folder shape (drive letter, forward slash, `/c/`, `\\?\` and UNC), with `HOME` read the way the adapters' Git Bash reads it.
|
|
24
|
+
- Changed: the host canary record shipped with the CLI is refreshed for this release build.
|
|
25
|
+
- The Rust hook engine now gives company and other folder hooks the same time limit as master-hook on every event. `HQ_MASTER_CHILD_TIMEOUT` (2 s on fleet bots) applies only to events whose hooks cannot block the tool call, such as PostToolUse and SessionStart. PreToolUse, UserPromptSubmit and the other events that can block use `HQ_MASTER_BLOCKING_CHILD_TIMEOUT` (default 120 s), so a slow guard such as a review gate that calls `gh pr view` is no longer cut off into a block. This applies only when the installed master-hook.sh uses the same rule (hq-core-staging #2152); with an older master-hook the engine keeps the old limits, and with a master-hook it cannot read this way it hands the event to master-hook. On fleet bots, the check that decides whether company hooks fit the native time budget now counts only the hooks one tool can start, so Indigo's two PostToolUse hooks (which take different tools) leave 2 s of the 5 s budget spare instead of none. When a hook's tool list cannot be read plainly, for example one with an empty entry such as `Bash,`, the check counts every hook. `hq-hook dispatch` now hands Stop and SubagentStop to master-hook when master-hook applies its shared Stop budget.
|
|
26
|
+
- Internal: inject a deterministic/manual budget clock (`BudgetSource`, `host::RunClock`, `core_next::main_with_clock`) into `hq-hook` dispatch tests (`host::chain`, `host_run` stdin-budget `#3952`, and the five master parity suites `#3954`) so time-budget tests no longer race against wall-clock time under CI load; production `hq-hook` keeps the real monotonic clock, and one real-time wall-clock budget smoke test runs on the nightly Linux schedule (`budget_realtime_perf`).
|
|
27
|
+
- The Rust hook engine's native PreToolUse now accepts the master-hook.sh from hq-core-staging #2152 (the version that gives folder hooks on events that can block their longer time limit). An HQ on that core keeps answering PreToolUse natively instead of falling back to the shell dispatcher.
|
|
28
|
+
- SessionStart folder hooks now get the longer `HQ_MASTER_BLOCKING_CHILD_TIMEOUT` limit (120 s by default, 8 s on fleet bots) in the Rust hook engine instead of `HQ_MASTER_CHILD_TIMEOUT`, matching master-hook.sh from hq-core-staging #2152 at f9a32c25. Native PreToolUse accepts that master-hook.sh in place of its earlier 0bec9205 revision, which kept SessionStart on the short limit; a root still on 0bec9205 hands its events to master-hook.
|
|
29
|
+
- Internal: in `host_run::jq_only_folder_augmentation_allows_benign_denies_protected_and_refuses_absent_jq` Part 7(c), assert that real-binary dispatch resolves the host's fixed candidate `jq` (such as `/opt/homebrew/bin/jq` on macOS) when one exists, and refuses with exit 2 when none exists (test-only).
|
|
30
|
+
- Internal: fix three macOS-native test assumptions in `policy_frontmatter` — symlink sibling `lib/` when copying dynamically linked Homebrew `node` into the headerless `distro-node` prefix (keeping `include/` absent), and probe whether `MallocStackLogging` emits stderr noise on the host `node` before asserting shell exit 2 while keeping native deny assertions unconditional (test-only).
|
|
31
|
+
- Internal: pass explicit `--new` engine command in `precompact_native::replay_finds_no_precompact_difference_on_any_host` so Grok PreCompact replay runs against the dispatcher snapshot without requiring `.grok/hooks/hq-grok-user-bridge.*` (test-only).
|
|
32
|
+
- Reverted: the fleet-local adapter PreToolUse and fleet merged-write-guard-shadow claims from #4000, which blocked fleet-local and direct agents-v2 tool calls on Windows.
|
|
33
|
+
- test(hq-hook): assert documented Windows fail-closed blocks in `credential_guard` parity suite
|
|
34
|
+
- test(hq-hook): expect Claude SessionStart to succeed natively on Windows in `host_run`
|
|
35
|
+
- test(hq-hook): assert fail-closed Windows refusals for POSIX-rooted fixtures in `run_starts_no_interpreter`
|
|
36
|
+
- Fixed: native `hq core handoff post` and its bundled `handoff-post.sh` fallback now apply the same local-only company check before calling `hq sync push`, honoring `company.yaml` `cloud: true` / `cloud: false` (where an explicit `cloud: false` overrides `companies/manifest.yaml`) and `companies/manifest.yaml` `cloud_uid`, and skipping local-only companies with the same log message and exit code.
|
|
37
|
+
- Internal: On Windows, Claude Code SessionStart dispatcher bookkeeping is now handled by the native hook engine.
|
|
38
|
+
- Internal: On Windows, Claude Code UserPromptSubmit dispatcher bookkeeping is now handled by the native hook engine.
|
|
39
|
+
- Claim `lanes-repo-merge-hold` on `fleet-local` and `agents-v2` with the desktop behaviour (owner decision "Same as desktops"): the native check decides from the hold records, refusing held repositories and allowing the rest, and starts no `hq`. The records are also read under the adapter's own HQ root, as the adapters export it. Differential parity tests against `fleet-local-v0.4.33.sh` and `agents-v2-6490142.sh` running the released shim, with each difference from the bot shell path recorded and tested.
|
|
40
|
+
- Fixed Windows path handling in `hq-hook` so drive-rooted, backslash, and verbatim working directories (`C:\...`, `\\?\C:\...`) normalize cleanly across repository-root lookups, path-normalization helpers, and shadow bridge runs without hanging or dropping ordinary paths.
|
|
41
|
+
- On Windows, the env-file guard refuses a bare option-like file name such as `-x.env ` or `-x.env.` that Windows saves as an env file.
|
|
42
|
+
|
|
43
|
+
## [5.345.260] — 2026-11-26
|
|
44
|
+
- Added: `hq reindex`, `hq rescue`, `hq sync` (every hq-cloud `sync()` leg), the first sync of `hq onboard` and the reindex after `hq sync-core reconcile` pass hq-cloud a `companySessions` option. For a person: the `prs_` person uid, the cloud-backed companies and an `uploadEvidence` lookup. For an agent (`HQ_MACHINE_CREDS_FILE`, or `~/.hq-agent/machine-creds.json` with no person session, or an `agt_` sign-in): `{ identity: "agent" }`, so its transcripts stay in its own vault. A company counts as cloud-backed when its `companies/manifest.yaml` entry has a `cmp_` `cloud_uid`, when the new sync engine runs or is handing back its vault, or when its `company.yaml` says `cloud: true` (an unreadable `company.yaml` counts as cloud-backed), and hq-cloud's personal-vault scope (`isCompanyInPersonalVaultScope`, else `computePersonalCompanySubdirs`) does not hold it. `personal` never counts. Folder names follow hq-cloud's rule (`^[A-Za-z0-9_-]+$`). The lookup reads the new sync engine's confirmed-upload ledger (`~/.hq/sync-core/engines/<cmp>/.hq/sync-core/state/push-only-confirmed/<cmp>.json`) for companies the engine owns in full, and answers nothing for companies on the current sync so hq-cloud uses its own journal. The ledger is read only when it and its folders are not symlinks, is at most 16 MiB and is valid JSON; malformed entries are skipped. The person uid is cached in `~/.hq/company-sessions/person-uid.json` for the signed-in account; a reindex from a hook never looks it up over the network, and other commands wait at most 10 s. When the uid is not known the option is left out, and the message, printed once, says company-bound transcripts are held on this computer. Nobody signed in: no option and no message. `HQ_COMPANY_SESSIONS_HOME` replaces the home folder for this routing (the test setup points it at a temp folder). This needs `@indigoai-us/hq-cloud` 6.18.127 (indigoai-us/hq-cloud#1180), which this release bundles.
|
|
45
|
+
- Added: every engine `config.toml` written by `hq sync-core reconcile` carries `person_uid = "prs_..."` under `[sync]` when the person uid is known (resolved, else cached), so the engine uploads `sessions/<uid>/` in company vaults (indigoai-us/hq-sync-core#242). Engines before that release ignore the key.
|
|
46
|
+
- Changed: on Windows, `hq-hook` can match a released hook script that a checkout rewrote with Windows line endings when the `hook-engine-crlf-pins` flag is enabled in the local flag snapshot; without it, behavior is unchanged.
|
|
47
|
+
- Changed: the host canary record shipped with the CLI is refreshed for this release build.
|
|
48
|
+
- Changed: version 5.345.259 was tagged but not published, so its changes ship in this release. The host canary record is rebuilt for the 5.345.260 build.
|
|
49
|
+
- Changed: hq-cli now uses hq-cloud 6.18.126. The sync runner keeps one upload memory budget (up to 1 GB) for the whole process instead of one per sync pass, and a file larger than the budget uploads one at a time alongside it, so small edits keep syncing while a large file uploads. The background reindex step has a fixed memory ceiling of 1024 MB (`HQ_REINDEX_WORKER_MAX_OLD_SPACE_MB` changes it, up to 3584); if it reaches the ceiling, only that step stops and sync carries on. While the runner uses 1 GB or more, the sync log gets one line a minute that splits its memory into heap, buffers and other memory. Token usage from busy machines now reaches HQ: each sync pass keeps uploading Claude Code, Codex and Grok transcript usage for up to 20 seconds (up to 6,000 rows each) instead of stopping at 400 rows, and picks up where it stopped on the next pass.
|
|
50
|
+
- On hq-agents-v2 bots, the Rust hook engine now does master-hook's own SessionStart work natively (session bind, twin dedupe, nested-install warning, scope pin, timeout journal), so `hq reindex` can move an agents-v2 SessionStart with the stock settings off the bash adapter. A twin start skips master-hook's folder hooks and keeps the registry hooks, as the adapter does. An input the native work does not model, such as a Task agent payload or a settings entry that starts master-hook for another event, is refused natively. Roots whose `core/scripts/lib/session-id.sh` is not the hq-core 16.0.48 to 16.0.50 revision stay on the adapter at registration, as before.
|
|
51
|
+
- The Rust hook engine's native PostToolUse for agents-v2 and fleet-local bots now reads a `hook-registry.json` matcher that uses regex syntax, such as `Agent|Task|Write|Edit|MultiEdit|NotebookEdit|Read|mcp__.*`, the same way the shell adapter matches it. A bot HQ with such a matcher now stays on the native engine for PostToolUse. Before, the engine handed every PostToolUse back to the adapter. A matcher the engine cannot read exactly still goes to the adapter.
|
|
52
|
+
- The Rust hook engine's native PreToolUse now reads the company scope script of the HQ it runs in. When that script is not one of the hq-core 16.0.45 to 16.0.52 revisions the native scope check answers for (for example the hq-core 16.0.53-beta.1 script, which also checks PowerShell tool calls), `hq reindex` keeps PreToolUse on the old dispatcher for Claude Code and Codex, and an HQ already on the new core refuses PreToolUse calls with a message that names the script and asks for `hq reindex`. An HQ on a released core is answered as before.
|
|
53
|
+
- hq-hook: the credential-file check on a very long command with many repeated words runs faster on Windows; its answers are unchanged.
|
|
54
|
+
- Fixed: the knowledge step of `hq core handoff run` now looks only at the company the session is bound to, as the hq-core handoff helper does. It used to check every company's knowledge folder and could list other companies' folders in its result. The session lock is read through the HQ root's own `core/scripts/hq-session.sh`, as the helper reads it, so a missing session library, a failing or slow lock read, or a host without bash leaves the session unbound. With no bound company the step reports `SKIPPED-COMPANY-KNOWLEDGE` with the reason, and a bound company's knowledge that is its own git repository has its listed files committed, both as the helper does.
|
|
55
|
+
- Fixed: the bundled `handoff-knowledge-commit.sh`, used by `hq core handoff-knowledge-commit` when the built-in route is off, is now hq-core's current helper and also reads only the bound company.
|
|
56
|
+
- Fixed: `hq core handoff run` and `hq core handoff finalize` build the thread id (`T-YYYYMMDD-HHMMSS-…`) from the local clock, as the hq-core helper does, so new thread ids sort in line with existing ones. `created_at` and the other timestamps stay in UTC.
|
|
57
|
+
- Fixed: native `hq core handoff-sync-prefetch` now snapshots a valid local `workspace/threads/handoff.json` pointer before pulling from the personal vault and restores it atomically if the pull lands an older `created_at`, removes the file, or writes non-object or invalid JSON.
|
|
58
|
+
- Fixed: `hq core handoff finalize` now runs the in-process continuity publish (`runHandoffSyncPublish`) by default and whenever `core/scripts/handoff-sync-publish.sh` is absent, instead of silently skipping publish. It follows the `core-native-handoff` kill switch (falling back to the installed script or bundled asset when disabled), pushes only the continuity pointer and its referenced thread file (falling back once to a full personal push on older CLIs), and leaves other companies' folders untouched.
|
|
59
|
+
- Fixed: native `conduct-link-inherit` standing rules and join failure logs in both `UserPromptSubmit` and `PostToolUse`/`PreToolUse` ports now choose `hq runners` on post-rename HQ core installs while preserving `hq lanes` on pre-rename installs, and native in-process join failures now match the CLI's `hq runners link:` prefix (US-035).
|
|
60
|
+
- Fixed: on Windows, HQ's check that a session is not running from a git worktree of HQ works again, at the start of a session and on each prompt. It had been turning every prompt away there.
|
|
61
|
+
- Claim `fleet-local-adapter:PreToolUse` on `fleet-local`, and `merged-write-guard-shadow` on `fleet-local` and `agents-v2` (`PreToolUse@agents-v2,fleet-local`). The fleet-local adapter check accepts a stock `hook-registry.json` whose rows the dispatcher reads, so each row is answered by its own member. On both hosts the shadow row records under the adapter's own HQ root and honours `HQ_FLEET_LOCAL_HOOK_SKIP` and `HQ_AGENTS_V2_HOOK_SKIP`. Differential parity tests against `fleet-local-v0.4.33.sh` and `agents-v2-6490142.sh`. `lanes-repo-merge-hold` stays unclaimed on both hosts pending an owner decision.
|
|
62
|
+
|
|
5
63
|
## [5.345.258] — 2026-11-26
|
|
6
64
|
- Fixed hooks switching between the hook engine and the shell scripts from one event to the next when an `hq` older than 5.345.252 also runs on the same machine. That older release asks for flags without reporting its version, gets a different answer, and saved it to the same local flag file. The CLI now saves flags to `snapshot-v2-<scope>.json`, and the CLI and `hq-hook` read only that file. The CLI still writes `snapshot-<scope>.json` with the same contents for older readers. Until a scope has a `snapshot-v2-` file, a feature that is turned off in its old file stays off; nothing else is read from the old file, so hook ports stay on the shell scripts until a current `hq` command or the daemon writes the new file.
|
|
7
65
|
- Changed: the host canary record shipped with the CLI is refreshed for this release build.
|
|
@@ -19,6 +19,26 @@ done
|
|
|
19
19
|
[ -n "$changeset" ] && [ -f "$changeset" ] || usage
|
|
20
20
|
root="$(cd "$root" && pwd -P)"
|
|
21
21
|
tmp_parent="$root/workspace/threads/.handoff-tmp"
|
|
22
|
+
|
|
23
|
+
# These commits run hooks. When the HQ git-hooks dispatcher is installed (a
|
|
24
|
+
# global core.hooksPath), its commit-msg hook stamps HQ-Fingerprint, so an
|
|
25
|
+
# explicit trailer here would be a second copy. Pass it only when no global
|
|
26
|
+
# hooks path is set, i.e. the dispatcher is absent. The trailer is loaded
|
|
27
|
+
# lazily, once, before the first commit, so a handoff with nothing to commit
|
|
28
|
+
# never pays for it. A failing lib leaves the array empty and never blocks the
|
|
29
|
+
# commit.
|
|
30
|
+
HQ_FINGERPRINT_TRAILER_ARGS=()
|
|
31
|
+
fingerprint_lib="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib/fingerprint.sh"
|
|
32
|
+
fingerprint_loaded=0
|
|
33
|
+
load_fingerprint_trailer_once() {
|
|
34
|
+
[ "$fingerprint_loaded" -eq 0 ] || return 0
|
|
35
|
+
fingerprint_loaded=1
|
|
36
|
+
if [ -z "$(git config --global --get core.hooksPath 2>/dev/null || true)" ] && [ -f "$fingerprint_lib" ]; then
|
|
37
|
+
# shellcheck source=lib/fingerprint.sh
|
|
38
|
+
{ . "$fingerprint_lib" 2>/dev/null && hq_fingerprint_trailer_load "$root"; } || HQ_FINGERPRINT_TRAILER_ARGS=()
|
|
39
|
+
fi
|
|
40
|
+
return 0
|
|
41
|
+
}
|
|
22
42
|
mkdir -p "$tmp_parent"
|
|
23
43
|
tmp_dir="$(mktemp -d "$tmp_parent/handoff-knowledge-commit.XXXXXX")"
|
|
24
44
|
trap 'rm -rf "$tmp_dir"' EXIT
|
|
@@ -31,7 +51,137 @@ jq -e 'def safe_path: type == "string" and length > 0 and (startswith("/") | not
|
|
|
31
51
|
exit 1
|
|
32
52
|
}
|
|
33
53
|
|
|
34
|
-
|
|
54
|
+
# Company scope: only the session's bound (primary) company is considered.
|
|
55
|
+
# Other companies' knowledge is never read or committed, including the other
|
|
56
|
+
# members of a multi-company lock (company_slugs). The bound company is
|
|
57
|
+
# HQ_ACTIVE_COMPANY; when that is empty (a company bound mid-session writes the
|
|
58
|
+
# session lock but cannot change the env of the running process) it is the
|
|
59
|
+
# lock's primary company_slug, read ONLY for a session id taken from the
|
|
60
|
+
# environment (session_id_from_env) and passed to hq-session.sh explicitly.
|
|
61
|
+
# workspace/sessions/.current is a global last-writer-wins pointer that can name
|
|
62
|
+
# another live session, so it is never used here. The reserved value "personal"
|
|
63
|
+
# means no company. A resolved slug must be a real directory under companies/
|
|
64
|
+
# and appear with exact case in companies/manifest.yaml, otherwise it is treated
|
|
65
|
+
# as unbound. With no bound company, company knowledge is skipped and the skip
|
|
66
|
+
# is reported with its reason.
|
|
67
|
+
skip_reason="no bound company"
|
|
68
|
+
|
|
69
|
+
# run_with_timeout <seconds> <cmd...>: timeout/gtimeout when present, else a
|
|
70
|
+
# background job with a bounded poll (portable to stock macOS).
|
|
71
|
+
run_with_timeout() {
|
|
72
|
+
local secs="$1"; shift
|
|
73
|
+
if command -v timeout >/dev/null 2>&1; then timeout "$secs" "$@"; return $?; fi
|
|
74
|
+
if command -v gtimeout >/dev/null 2>&1; then gtimeout "$secs" "$@"; return $?; fi
|
|
75
|
+
# Fallback. Call this only from a background subshell (see the lock read
|
|
76
|
+
# below): the TERM/INT/HUP trap set here then never replaces the main shell's
|
|
77
|
+
# traps. The output file lives in $tmp_dir, which the main EXIT trap removes.
|
|
78
|
+
{
|
|
79
|
+
out="$(mktemp "$tmp_dir/hkc-timeout.XXXXXX")" || exit 1
|
|
80
|
+
pid=""
|
|
81
|
+
kill_tree() {
|
|
82
|
+
local parent="$1" child
|
|
83
|
+
for child in $(pgrep -P "$parent" 2>/dev/null); do kill_tree "$child"; done
|
|
84
|
+
kill "$parent" 2>/dev/null || true
|
|
85
|
+
}
|
|
86
|
+
cleanup_job() {
|
|
87
|
+
[ -z "$pid" ] || { kill_tree "$pid"; wait "$pid" 2>/dev/null || true; }
|
|
88
|
+
rm -f "$out"
|
|
89
|
+
}
|
|
90
|
+
trap 'cleanup_job; exit 143' TERM INT HUP
|
|
91
|
+
"$@" >"$out" 2>/dev/null &
|
|
92
|
+
pid=$!
|
|
93
|
+
i=0
|
|
94
|
+
while [ "$i" -lt $((secs * 10)) ]; do
|
|
95
|
+
kill -0 "$pid" 2>/dev/null || break
|
|
96
|
+
sleep 0.1
|
|
97
|
+
i=$((i + 1))
|
|
98
|
+
done
|
|
99
|
+
if kill -0 "$pid" 2>/dev/null; then
|
|
100
|
+
cleanup_job
|
|
101
|
+
exit 124
|
|
102
|
+
fi
|
|
103
|
+
rc=0
|
|
104
|
+
wait "$pid" || rc=$?
|
|
105
|
+
cat "$out"; rm -f "$out"
|
|
106
|
+
exit "$rc"
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
# company_is_registered <slug>: real (non-symlink) company directory and an
|
|
111
|
+
# exact-case key under companies: in companies/manifest.yaml.
|
|
112
|
+
company_is_registered() {
|
|
113
|
+
local slug="$1" manifest="$root/companies/manifest.yaml" company_dir="$root/companies/$1"
|
|
114
|
+
[ -d "$company_dir" ] && [ ! -L "$company_dir" ] || return 1
|
|
115
|
+
[ -f "$manifest" ] || return 1
|
|
116
|
+
awk -v want="$slug" '
|
|
117
|
+
/^companies:[[:space:]]*$/ { inco = 1; next }
|
|
118
|
+
inco && /^[^[:space:]#]/ { inco = 0 }
|
|
119
|
+
inco && match($0, /^ [^[:space:]#][^:]*:/) {
|
|
120
|
+
key = substr($0, 3, RLENGTH - 3)
|
|
121
|
+
if (key == want) { found = 1; exit }
|
|
122
|
+
}
|
|
123
|
+
END { exit found ? 0 : 1 }' "$manifest" 2>/dev/null
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
bound_company="${HQ_ACTIVE_COMPANY:-}"
|
|
127
|
+
# The reserved value "personal" means no company, same as the lock route; do not
|
|
128
|
+
# fall through to the session lock.
|
|
129
|
+
if [ "$bound_company" = personal ]; then
|
|
130
|
+
bound_company=""
|
|
131
|
+
elif [ -z "$bound_company" ]; then
|
|
132
|
+
lock_session_id=""
|
|
133
|
+
lib_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
134
|
+
if [ -f "$lib_dir/lib/session-id.sh" ]; then
|
|
135
|
+
# shellcheck source=lib/session-id.sh
|
|
136
|
+
. "$lib_dir/lib/session-id.sh" 2>/dev/null || true
|
|
137
|
+
if declare -F session_id_from_env >/dev/null 2>&1; then
|
|
138
|
+
lock_session_id="$(session_id_from_env)"
|
|
139
|
+
fi
|
|
140
|
+
fi
|
|
141
|
+
if [ -z "$lock_session_id" ]; then
|
|
142
|
+
skip_reason="no bound company (no session id in the environment, session lock not read)"
|
|
143
|
+
elif [ ! -f "$lib_dir/hq-session.sh" ]; then
|
|
144
|
+
skip_reason="session lock unreadable"
|
|
145
|
+
else
|
|
146
|
+
lock_meta="$root/workspace/sessions/$lock_session_id/meta.yaml"
|
|
147
|
+
if [ -e "$lock_meta" ] && [ ! -r "$lock_meta" ]; then
|
|
148
|
+
skip_reason="session lock unreadable"
|
|
149
|
+
else
|
|
150
|
+
# Run the read as a background job and wait, so a TERM to this helper is
|
|
151
|
+
# handled at once and takes the job (and its children) down with it.
|
|
152
|
+
lock_out_file="$tmp_dir/lock-out"
|
|
153
|
+
HQ_ROOT="$root" HQ_HQ_SESSION_NO_CLI=1 \
|
|
154
|
+
run_with_timeout "${HQ_HANDOFF_LOCK_TIMEOUT:-5}" bash "$lib_dir/hq-session.sh" --session-id "$lock_session_id" get company_slug \
|
|
155
|
+
>"$lock_out_file" &
|
|
156
|
+
lock_job=$!
|
|
157
|
+
trap 'kill -TERM "$lock_job" 2>/dev/null || true; wait "$lock_job" 2>/dev/null || true; exit 143' TERM INT HUP
|
|
158
|
+
lock_rc=0
|
|
159
|
+
wait "$lock_job" || lock_rc=$?
|
|
160
|
+
trap - TERM INT HUP
|
|
161
|
+
if [ "$lock_rc" -eq 0 ]; then
|
|
162
|
+
lock_out="$(cat "$lock_out_file")"
|
|
163
|
+
bound_company="$(printf '%s' "$lock_out" | tr -d '[:space:]')"
|
|
164
|
+
[ "$bound_company" != personal ] || bound_company=""
|
|
165
|
+
else
|
|
166
|
+
skip_reason="session lock unreadable"
|
|
167
|
+
fi
|
|
168
|
+
fi
|
|
169
|
+
fi
|
|
170
|
+
fi
|
|
171
|
+
company_knowledge=()
|
|
172
|
+
if [ -n "$bound_company" ]; then
|
|
173
|
+
if [[ "$bound_company" =~ ^[A-Za-z0-9_-]+$ ]] && company_is_registered "$bound_company"; then
|
|
174
|
+
company_knowledge=("$root/companies/$bound_company/knowledge")
|
|
175
|
+
else
|
|
176
|
+
skip_reason="company '$bound_company' is not a registered company"
|
|
177
|
+
bound_company=""
|
|
178
|
+
fi
|
|
179
|
+
fi
|
|
180
|
+
if [ -z "$bound_company" ]; then
|
|
181
|
+
echo "SKIPPED-COMPANY-KNOWLEDGE: $skip_reason; company knowledge repositories were not processed"
|
|
182
|
+
fi
|
|
183
|
+
|
|
184
|
+
for knowledge_path in "$root"/core/knowledge/public/* "$root"/core/knowledge/private/* "$root"/personal/knowledge/* ${company_knowledge[@]+"${company_knowledge[@]}"}; do
|
|
35
185
|
[ -e "$knowledge_path" ] || [ -L "$knowledge_path" ] || continue
|
|
36
186
|
knowledge_rel="${knowledge_path#"$root"/}"
|
|
37
187
|
if [ -L "$knowledge_path" ]; then
|
|
@@ -53,9 +203,8 @@ for knowledge_path in "$root"/core/knowledge/public/* "$root"/core/knowledge/pri
|
|
|
53
203
|
esac
|
|
54
204
|
continue
|
|
55
205
|
fi
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
esac
|
|
206
|
+
# A plain company knowledge directory syncs through its vault; only a bound
|
|
207
|
+
# company's knowledge that is its own git repository is committed here.
|
|
59
208
|
[ -e "$knowledge_path/.git" ] || continue
|
|
60
209
|
repo_dir="$(git -C "$knowledge_path" rev-parse --show-toplevel 2>/dev/null)" || continue
|
|
61
210
|
knowledge_real="$(cd "$knowledge_path" && pwd -P)"
|
|
@@ -109,7 +258,8 @@ for knowledge_path in "$root"/core/knowledge/public/* "$root"/core/knowledge/pri
|
|
|
109
258
|
changed="$(git -C "$repo_dir" status --porcelain -- "${repo_paths[@]}")"
|
|
110
259
|
[ -n "$changed" ] || continue
|
|
111
260
|
git -C "$repo_dir" add -- "${repo_paths[@]}"
|
|
112
|
-
|
|
261
|
+
load_fingerprint_trailer_once
|
|
262
|
+
git -C "$repo_dir" commit --only -m "checkpoint: save session knowledge changes" ${HQ_FINGERPRINT_TRAILER_ARGS[@]+"${HQ_FINGERPRINT_TRAILER_ARGS[@]}"} -- "${repo_paths[@]}"
|
|
113
263
|
done
|
|
114
264
|
|
|
115
265
|
while IFS= read -r touched_path; do
|
|
@@ -119,5 +269,13 @@ while IFS= read -r touched_path; do
|
|
|
119
269
|
echo "NOT-COMMITTED: $touched_path is listed in the handoff changeset but no knowledge repository committed it"
|
|
120
270
|
fi
|
|
121
271
|
;;
|
|
272
|
+
companies/*/knowledge/*)
|
|
273
|
+
[ -n "$bound_company" ] || continue
|
|
274
|
+
case "$touched_path" in "companies/$bound_company/knowledge/"*) ;; *) continue ;; esac
|
|
275
|
+
[ -e "$root/companies/$bound_company/knowledge/.git" ] || continue
|
|
276
|
+
if ! grep -Fqx -- "$touched_path" "$handled_paths"; then
|
|
277
|
+
echo "NOT-COMMITTED: $touched_path is listed in the handoff changeset but no knowledge repository committed it"
|
|
278
|
+
fi
|
|
279
|
+
;;
|
|
122
280
|
esac
|
|
123
281
|
done < <(jq -r '.[] | if type == "string" then . else .path end' "$changeset")
|
|
@@ -170,9 +170,39 @@ if [[ -n "$THREAD_PATH" && -f "$THREAD_PATH" ]] && command -v hq >/dev/null 2>&1
|
|
|
170
170
|
log "workspace-sync: mirror hook unavailable for handoff thread"
|
|
171
171
|
fi
|
|
172
172
|
fi
|
|
173
|
+
# handoff_company_is_cloud <slug> — true when the company has a cloud vault.
|
|
174
|
+
# company.yaml `cloud: true` says so directly. Many cloud companies have no
|
|
175
|
+
# company.yaml (or no cloud: line) and are known only by their manifest
|
|
176
|
+
# cloud_uid; they used to be skipped as local-only
|
|
177
|
+
# (feedback_98f2ce49-5065-4670-8544-1a3dccd9985e). An explicit `cloud: false`
|
|
178
|
+
# still wins over the manifest.
|
|
179
|
+
handoff_company_is_cloud() {
|
|
180
|
+
local co="$1" yaml="$HQ_ROOT/companies/$1/company.yaml"
|
|
181
|
+
if [[ -f "$yaml" ]]; then
|
|
182
|
+
grep -Eq '^cloud:[[:space:]]*"?true"?([[:space:]]|#|$)' "$yaml" && return 0
|
|
183
|
+
grep -Eq '^cloud:[[:space:]]*"?false"?([[:space:]]|#|$)' "$yaml" && return 1
|
|
184
|
+
fi
|
|
185
|
+
[[ -f "$HQ_ROOT/companies/manifest.yaml" ]] || return 1
|
|
186
|
+
awk -v co="$co" '
|
|
187
|
+
/^[^[:space:]#]/ { in_companies = ($0 ~ /^companies:[[:space:]]*$/); in_co = 0; next }
|
|
188
|
+
in_companies && /^ [^[:space:]#][^:]*:/ { k = $1; sub(/:$/, "", k); gsub(/["\047]/, "", k); in_co = (k == co); next }
|
|
189
|
+
in_companies && in_co && /^ cloud_uid:/ {
|
|
190
|
+
v = $0; sub(/^ cloud_uid:[[:space:]]*/, "", v); gsub(/["\047\r[:space:]]/, "", v)
|
|
191
|
+
if (v != "" && v != "null" && v != "~") found = 1
|
|
192
|
+
}
|
|
193
|
+
END { exit !found }
|
|
194
|
+
' "$HQ_ROOT/companies/manifest.yaml"
|
|
195
|
+
}
|
|
173
196
|
while IFS= read -r company; do
|
|
174
197
|
[[ "$company" =~ ^[a-z][a-z0-9_-]*$ ]] || continue
|
|
175
198
|
[[ -d "$HQ_ROOT/companies/$company/workspace" ]] || continue
|
|
199
|
+
# Local-only companies have no cloud vault. Pushing them fails with
|
|
200
|
+
# "No entity in caller's namespace matches company/<slug>" and a
|
|
201
|
+
# wrong-identity hint even when the operator is signed in correctly.
|
|
202
|
+
if ! handoff_company_is_cloud "$company"; then
|
|
203
|
+
log "workspace-sync: skipped (company is local-only: no cloud: true and no manifest cloud_uid)"
|
|
204
|
+
continue
|
|
205
|
+
fi
|
|
176
206
|
if [[ "$THREAD_MIRRORABLE" != "true" || \
|
|
177
207
|
! -f "$HQ_ROOT/companies/$company/workspace/sessions/$THREAD_ID.json" ]]; then
|
|
178
208
|
log "workspace-sync: skipped (thread mirror missing for $company)"
|
|
@@ -98,12 +98,51 @@ run_with_timeout() {
|
|
|
98
98
|
return "$rc"
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
# The pull lands the vault's copy of workspace/threads/handoff.json over the
|
|
102
|
+
# local one. The vault copy can be OLDER than what this machine already has
|
|
103
|
+
# (a handoff finalized here minutes ago that the vault has not caught up to,
|
|
104
|
+
# or a stale replay): seen 2026-10-25 when an 11:46 pointer replaced a 22:06
|
|
105
|
+
# one and the newer session's archive check then refused. Snapshot the local
|
|
106
|
+
# pointer first and, if the pull regressed it by created_at, put the newer one
|
|
107
|
+
# back. A pulled pointer that is not valid JSON never replaces a valid one.
|
|
108
|
+
POINTER="$HQ_ROOT/workspace/threads/handoff.json"
|
|
109
|
+
POINTER_SNAPSHOT=""
|
|
110
|
+
if [[ -f "$POINTER" ]] && command -v jq >/dev/null 2>&1 \
|
|
111
|
+
&& jq -e 'type == "object"' "$POINTER" >/dev/null 2>&1; then
|
|
112
|
+
POINTER_SNAPSHOT="$(mktemp "${TMPDIR:-/tmp}/handoff-pointer-snapshot.XXXXXX")"
|
|
113
|
+
cp "$POINTER" "$POINTER_SNAPSHOT" 2>/dev/null || { rm -f "$POINTER_SNAPSHOT"; POINTER_SNAPSHOT=""; }
|
|
114
|
+
fi
|
|
115
|
+
|
|
101
116
|
rc=0
|
|
102
117
|
run_with_timeout "$TIMEOUT" \
|
|
103
118
|
hq sync pull --personal --hq-root "$HQ_ROOT" --lock-timeout 0 \
|
|
104
119
|
|| rc=$?
|
|
105
120
|
printf 'exit=%s\n' "$rc" >>"$LOG"
|
|
106
121
|
|
|
122
|
+
if [[ -n "$POINTER_SNAPSHOT" ]]; then
|
|
123
|
+
keep_local=0
|
|
124
|
+
if [[ ! -f "$POINTER" ]] || ! jq -e 'type == "object"' "$POINTER" >/dev/null 2>&1; then
|
|
125
|
+
keep_local=1
|
|
126
|
+
else
|
|
127
|
+
local_ts="$(jq -r '.created_at // empty' "$POINTER_SNAPSHOT" 2>/dev/null || true)"
|
|
128
|
+
pulled_ts="$(jq -r '.created_at // empty' "$POINTER" 2>/dev/null || true)"
|
|
129
|
+
if [[ -n "$local_ts" && -n "$pulled_ts" && "$pulled_ts" < "$local_ts" ]]; then
|
|
130
|
+
keep_local=1
|
|
131
|
+
fi
|
|
132
|
+
fi
|
|
133
|
+
if [[ "$keep_local" = 1 ]]; then
|
|
134
|
+
restore_tmp="$(mktemp "$(dirname "$POINTER")/.handoff-pointer.XXXXXX")"
|
|
135
|
+
if cp "$POINTER_SNAPSHOT" "$restore_tmp" && mv -f "$restore_tmp" "$POINTER"; then
|
|
136
|
+
printf 'kept newer local handoff pointer (local created_at=%s, pulled created_at=%s)\n' \
|
|
137
|
+
"${local_ts:-?}" "${pulled_ts:-invalid}" >>"$LOG"
|
|
138
|
+
else
|
|
139
|
+
rm -f "$restore_tmp"
|
|
140
|
+
printf 'could not restore the newer local handoff pointer\n' >>"$LOG"
|
|
141
|
+
fi
|
|
142
|
+
fi
|
|
143
|
+
rm -f "$POINTER_SNAPSHOT"
|
|
144
|
+
fi
|
|
145
|
+
|
|
107
146
|
case "$rc" in
|
|
108
147
|
0) echo "ok" ;;
|
|
109
148
|
124) echo "timed-out" ;;
|
|
@@ -92,14 +92,62 @@ run_with_timeout() {
|
|
|
92
92
|
return "$rc"
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
# continuity_paths: print the absolute paths the continuity push must carry:
|
|
96
|
+
# the pointer and the one thread file it references. A thread_path that is
|
|
97
|
+
# not a plain file under workspace/threads/ is ignored (same containment rule
|
|
98
|
+
# as hq-cloud computeContinuityPointerPaths).
|
|
99
|
+
continuity_paths() {
|
|
100
|
+
local pointer="$HQ_ROOT/workspace/threads/handoff.json"
|
|
101
|
+
[[ -f "$pointer" ]] || return 0
|
|
102
|
+
printf '%s\n' "$pointer"
|
|
103
|
+
local tp
|
|
104
|
+
tp="$(sed -n 's/.*"thread_path"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$pointer" | head -n1)"
|
|
105
|
+
case "$tp" in
|
|
106
|
+
workspace/threads/*) ;;
|
|
107
|
+
*) return 0 ;;
|
|
108
|
+
esac
|
|
109
|
+
case "/$tp/" in
|
|
110
|
+
*/../*|*/./*) return 0 ;;
|
|
111
|
+
esac
|
|
112
|
+
if [[ -f "$HQ_ROOT/$tp" ]]; then printf '%s\n' "$HQ_ROOT/$tp"; fi
|
|
113
|
+
return 0
|
|
114
|
+
}
|
|
115
|
+
|
|
95
116
|
run_publish() {
|
|
96
117
|
# `hq sync push --personal` is the canonical publish path for the session
|
|
97
|
-
# continuity pointer
|
|
98
|
-
# referenced thread file). A `--lock-timeout 0` keeps the push from queueing
|
|
118
|
+
# continuity pointer. A `--lock-timeout 0` keeps the push from queueing
|
|
99
119
|
# behind a long-running sync pass; the operator can rerun later.
|
|
120
|
+
#
|
|
121
|
+
# Push only the pointer and its thread file. A bare `--personal` push walks
|
|
122
|
+
# the whole personal scope, including thousands of workspace/.session-logs
|
|
123
|
+
# files, and never reaches the pointer inside the timebox. The stale vault
|
|
124
|
+
# copy then gets pulled back over the fresh local pointer.
|
|
125
|
+
local paths=()
|
|
126
|
+
local p
|
|
127
|
+
while IFS= read -r p; do
|
|
128
|
+
[[ -n "$p" ]] && paths+=("$p")
|
|
129
|
+
done < <(continuity_paths)
|
|
130
|
+
if [[ ${#paths[@]} -eq 0 ]]; then
|
|
131
|
+
echo "handoff-sync-publish: no continuity pointer to publish" >>"$LOG"
|
|
132
|
+
return 0
|
|
133
|
+
fi
|
|
134
|
+
|
|
135
|
+
local rc=0
|
|
100
136
|
run_with_timeout "$TIMEOUT" \
|
|
101
137
|
hq sync push --personal --hq-root "$HQ_ROOT" --lock-timeout 0 \
|
|
102
|
-
--message "handoff continuity pointer"
|
|
138
|
+
--message "handoff continuity pointer" "${paths[@]}" || rc=$?
|
|
139
|
+
# CLIs without targeted personal pushes (or with the
|
|
140
|
+
# cli.personal-targeted-push-paths flag off) refuse `--personal` with
|
|
141
|
+
# explicit paths. Only then fall back to the full personal push.
|
|
142
|
+
if [[ "$rc" -ne 0 && "$rc" -ne 124 ]] \
|
|
143
|
+
&& tail -n 20 "$LOG" 2>/dev/null | grep -q 'cannot be combined with explicit \[paths\]'; then
|
|
144
|
+
echo "handoff-sync-publish: targeted push refused by this CLI; falling back to full personal push" >>"$LOG"
|
|
145
|
+
rc=0
|
|
146
|
+
run_with_timeout "$TIMEOUT" \
|
|
147
|
+
hq sync push --personal --hq-root "$HQ_ROOT" --lock-timeout 0 \
|
|
148
|
+
--message "handoff continuity pointer" || rc=$?
|
|
149
|
+
fi
|
|
150
|
+
return "$rc"
|
|
103
151
|
}
|
|
104
152
|
|
|
105
153
|
mkdir -p "$(dirname "$LOG")" 2>/dev/null || true
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": "hq.host-canary-release.v1",
|
|
3
|
-
"cliVersion": "5.345.
|
|
3
|
+
"cliVersion": "5.345.261",
|
|
4
4
|
"hosts": {
|
|
5
5
|
"claude": [
|
|
6
6
|
{
|
|
7
7
|
"passed": true,
|
|
8
|
-
"at": "2026-11-
|
|
9
|
-
"engineVersion": "0.3.1+hq.5.345.
|
|
8
|
+
"at": "2026-11-26T12:12:28.930Z",
|
|
9
|
+
"engineVersion": "0.3.1+hq.5.345.261.src.6599dfcb673f514942b5a9bc7aea662654013c5013127224466562049bb8da9c",
|
|
10
10
|
"gateSha256": "a2879dfe692233f5953bac86672947bbd82f3c5247292f3efcb80f16c3d2c6b1"
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
13
|
"passed": true,
|
|
14
|
-
"at": "2026-11-
|
|
15
|
-
"engineVersion": "0.3.1+hq.5.345.
|
|
14
|
+
"at": "2026-11-26T12:12:55.594Z",
|
|
15
|
+
"engineVersion": "0.3.1+hq.5.345.261.src.6599dfcb673f514942b5a9bc7aea662654013c5013127224466562049bb8da9c",
|
|
16
16
|
"gateSha256": "ca58a94859eae0a345c11c8d9c59303eb76350dc1cf223391037d21979c28718"
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
"passed": true,
|
|
20
|
-
"at": "2026-11-
|
|
21
|
-
"engineVersion": "0.3.1+hq.5.345.
|
|
20
|
+
"at": "2026-11-26T12:13:22.264Z",
|
|
21
|
+
"engineVersion": "0.3.1+hq.5.345.261.src.6599dfcb673f514942b5a9bc7aea662654013c5013127224466562049bb8da9c",
|
|
22
22
|
"gateSha256": "ecdbab7c2e0a1d94eb9c98f15e760390f215bc7115a217ded24b4275322722d2"
|
|
23
23
|
}
|
|
24
24
|
]
|
package/dist/commands/cloud.d.ts
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import { Command } from "commander";
|
|
17
17
|
import { type CliManifestTarget } from "../lib/sync/cli-manifest-reconcile.js";
|
|
18
18
|
import { VaultClient, scopeLookupSkipMessage, SyncScopeLookupError, type ConflictStrategy, type EntityContext, type MembershipSyncConfig, type SyncMode, type PullScope, type ExplicitGrant, type ShareOptions, type VaultServiceConfig } from "@indigoai-us/hq-cloud";
|
|
19
|
+
import { resolveCanonicalPersonUid } from "../lib/canonical-person.js";
|
|
19
20
|
import { withSyncWatchdog, type SyncWatchdogLimits } from "../utils/sync-watchdog.js";
|
|
20
21
|
import { type BannerLevel } from "../lib/narrow-hint-banner.js";
|
|
21
22
|
import { type PlanLimitRefusalSummary } from "../lib/billing/plan-limit-refusals.js";
|
|
@@ -608,13 +609,7 @@ export declare function pushShareCredentials(input: {
|
|
|
608
609
|
vaultConfig?: VaultServiceConfig;
|
|
609
610
|
scopeVaultConfig?: VaultServiceConfig;
|
|
610
611
|
}): Pick<ShareOptions, "entityContext" | "vaultConfig" | "privateFolderVaultConfig">;
|
|
611
|
-
|
|
612
|
-
* Resolve the canonical person entity UID for the logged-in user. Used by
|
|
613
|
-
* `hq sync {push,pull,now} --personal` to target the personal vault without
|
|
614
|
-
* the caller needing to know the UID. Throws a clean error if the user has
|
|
615
|
-
* no person entity (typically means they haven't run `hq onboard`).
|
|
616
|
-
*/
|
|
617
|
-
export declare function resolveCanonicalPersonUid(vaultClient: PullAllVaultClient): Promise<string>;
|
|
612
|
+
export { resolveCanonicalPersonUid };
|
|
618
613
|
/**
|
|
619
614
|
* Keep `hq sync push --personal <path>` refused by default. Positional paths
|
|
620
615
|
* bypass `computePersonalVaultPaths` and can send excluded `companies/`,
|
package/dist/commands/cloud.js
CHANGED
|
@@ -23,6 +23,7 @@ import * as fs from "fs";
|
|
|
23
23
|
import * as path from "path";
|
|
24
24
|
import { share, getStateDir, listJournals, createIgnoreFilter, VaultClient, computePersonalVaultPaths, PERSONAL_VAULT_JOURNAL_SLUG, resolvePullScope, readSyncProgress, syncDoctor, isTerminalIdentityRefusal, scopeLookupSkipMessage, SyncScopeLookupError, } from "@indigoai-us/hq-cloud";
|
|
25
25
|
import { syncLeg, syncUnderOperationLock } from "../utils/sync-operation-lock.js";
|
|
26
|
+
import { pickCanonicalPerson, resolveCanonicalPersonUid } from "../lib/canonical-person.js";
|
|
26
27
|
import { keyedSyncPull } from "./keyed-sync-pull.js";
|
|
27
28
|
import { SYNC_WATCHDOG_EXIT_CODE, SYNC_WATCHDOG_REPORT_GRACE_MS, SyncWatchdogTimeoutError, createSnapshotProgressProbe, resolveSyncWatchdogLimits, withSyncWatchdog, } from "../utils/sync-watchdog.js";
|
|
28
29
|
import { DEFAULT_HQ_ROOT, ensureCognitoToken, buildVaultConfig, IdentitySwapRefusal, cognitoCachePrincipalUid, isDefinitivePersonAuthRejection, isIdentitySwapRefusal, loadCachedTokens, refreshCachedSession, } from "../utils/cognito-session.js";
|
|
@@ -775,19 +776,6 @@ export function configureSyncLockTimeout(raw) {
|
|
|
775
776
|
}
|
|
776
777
|
process.env.HQ_OP_LOCK_TIMEOUT = String(seconds);
|
|
777
778
|
}
|
|
778
|
-
// Oldest-first by createdAt, ties broken by uid lexicographic — matches
|
|
779
|
-
// `pickCanonicalPersonEntity` in @indigoai-us/hq-cloud so the CLI lands on
|
|
780
|
-
// the same person bucket that `hq-sync-runner` picks.
|
|
781
|
-
function pickCanonicalPerson(persons) {
|
|
782
|
-
const onlyPersons = persons.filter((e) => e.type === "person");
|
|
783
|
-
if (onlyPersons.length === 0)
|
|
784
|
-
return null;
|
|
785
|
-
return [...onlyPersons].sort((a, b) => {
|
|
786
|
-
if (a.createdAt !== b.createdAt)
|
|
787
|
-
return a.createdAt < b.createdAt ? -1 : 1;
|
|
788
|
-
return a.uid < b.uid ? -1 : 1;
|
|
789
|
-
})[0];
|
|
790
|
-
}
|
|
791
779
|
/**
|
|
792
780
|
* Read the sessions-exclusion prefix set off a resolved {@link PullScope}.
|
|
793
781
|
*
|
|
@@ -1223,22 +1211,7 @@ export function pushShareCredentials(input) {
|
|
|
1223
1211
|
}
|
|
1224
1212
|
return input.vaultConfig ? { vaultConfig: input.vaultConfig } : {};
|
|
1225
1213
|
}
|
|
1226
|
-
|
|
1227
|
-
* Resolve the canonical person entity UID for the logged-in user. Used by
|
|
1228
|
-
* `hq sync {push,pull,now} --personal` to target the personal vault without
|
|
1229
|
-
* the caller needing to know the UID. Throws a clean error if the user has
|
|
1230
|
-
* no person entity (typically means they haven't run `hq onboard`).
|
|
1231
|
-
*/
|
|
1232
|
-
export async function resolveCanonicalPersonUid(vaultClient) {
|
|
1233
|
-
const persons = await vaultClient.listPersonEntities();
|
|
1234
|
-
const pick = pickCanonicalPerson(persons);
|
|
1235
|
-
if (!pick) {
|
|
1236
|
-
throw new Error("No personal vault found for the logged-in user. Run `hq onboard` " +
|
|
1237
|
-
"first, or check `hq whoami` to confirm you're signed in to the " +
|
|
1238
|
-
"right account.");
|
|
1239
|
-
}
|
|
1240
|
-
return pick.uid;
|
|
1241
|
-
}
|
|
1214
|
+
export { resolveCanonicalPersonUid };
|
|
1242
1215
|
/**
|
|
1243
1216
|
* Keep `hq sync push --personal <path>` refused by default. Positional paths
|
|
1244
1217
|
* bypass `computePersonalVaultPaths` and can send excluded `companies/`,
|
|
@@ -18,7 +18,28 @@ declare function safePath(value: unknown): value is string;
|
|
|
18
18
|
declare function validChangeset(value: unknown): value is (string | {
|
|
19
19
|
path: string;
|
|
20
20
|
})[];
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* The session's bound company, resolved as handoff-knowledge-commit.sh does.
|
|
23
|
+
* Only this one company's knowledge is ever looked at; other companies,
|
|
24
|
+
* including the other members of a multi-company lock, are never read.
|
|
25
|
+
*
|
|
26
|
+
* HQ_ACTIVE_COMPANY first ("personal" means no company). When it is empty, the
|
|
27
|
+
* primary `company_slug` of the session lock, read only for a session id taken
|
|
28
|
+
* from the environment; workspace/sessions/.current is never used because it
|
|
29
|
+
* can name another live session. The lock is read by running the HQ root's own
|
|
30
|
+
* `core/scripts/hq-session.sh --session-id <id> get company_slug`, as the
|
|
31
|
+
* helper does, so a missing library, a failing or slow script, or no bash
|
|
32
|
+
* leaves the session unbound. The slug must be a real (non-symlink) directory
|
|
33
|
+
* under companies/ and an exact-case key under `companies:` in
|
|
34
|
+
* companies/manifest.yaml. With no bound company, `skipReason` says why.
|
|
35
|
+
*/
|
|
36
|
+
export type BoundKnowledgeCompany = {
|
|
37
|
+
company: string;
|
|
38
|
+
skipReason: string;
|
|
39
|
+
};
|
|
40
|
+
declare function companyIsRegistered(root: string, slug: string): boolean;
|
|
41
|
+
export declare function resolveBoundKnowledgeCompany(root: string, env?: NodeJS.ProcessEnv): BoundKnowledgeCompany;
|
|
42
|
+
declare function entriesUnder(root: string, boundCompany?: string): string[];
|
|
22
43
|
declare function gitRoot(git: GitRunner, cwd: string): string;
|
|
23
44
|
declare function statusPaths(git: GitRunner, repo: string, relative: string): {
|
|
24
45
|
paths: string[];
|
|
@@ -32,11 +53,12 @@ declare function parseNulPaths(status: string): {
|
|
|
32
53
|
paths: string[];
|
|
33
54
|
originals: string[];
|
|
34
55
|
};
|
|
35
|
-
export declare function runHandoffKnowledgeCommit(args: readonly string[], cwd?: string, git?: GitRunner, buildFingerprint?: FingerprintBuilder): KnowledgeCommitResult;
|
|
56
|
+
export declare function runHandoffKnowledgeCommit(args: readonly string[], cwd?: string, git?: GitRunner, buildFingerprint?: FingerprintBuilder, env?: NodeJS.ProcessEnv): KnowledgeCommitResult;
|
|
36
57
|
export declare const __handoffKnowledgeTest: {
|
|
37
58
|
safePath: typeof safePath;
|
|
38
59
|
validChangeset: typeof validChangeset;
|
|
39
60
|
entriesUnder: typeof entriesUnder;
|
|
61
|
+
companyIsRegistered: typeof companyIsRegistered;
|
|
40
62
|
statusPaths: typeof statusPaths;
|
|
41
63
|
parseNulPaths: typeof parseNulPaths;
|
|
42
64
|
expandTouched: typeof expandTouched;
|