@indigoai-us/hq-cli 5.345.238 → 5.345.242
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 +74 -0
- package/assets/scaffold/core/scripts/hq-delegate-grant.sh +170 -8
- package/assets/scaffold/core/scripts/hq-delegate-publish.sh +21 -1
- package/assets/scaffold/core/scripts/hq-delegate-repo.sh +7 -1
- package/assets/scaffold/core/scripts/hq-delegate-secrets.sh +95 -20
- package/assets/scaffold/core/scripts/hq-delegate-transfer.sh +57 -9
- package/assets/scaffold/core/scripts/lib/delegate-engine.sh +77 -0
- package/dist/command-catalog.generated.d.ts +212 -10
- package/dist/command-catalog.generated.js +260 -10
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -0
- package/dist/commands/cloud-off-gate.d.ts +9 -8
- package/dist/commands/cloud-off-gate.js +41 -40
- package/dist/commands/cloud.d.ts +17 -2
- package/dist/commands/cloud.js +126 -24
- package/dist/commands/core-delegate-w1b.js +333 -27
- package/dist/commands/core-delegate.d.ts +2 -1
- package/dist/commands/core-delegate.js +209 -48
- package/dist/commands/core-handoff.js +1 -1
- package/dist/commands/core-job-model-auth.d.ts +95 -0
- package/dist/commands/core-job-model-auth.js +247 -0
- package/dist/commands/core-job-run-native.js +280 -12
- package/dist/commands/core.js +1 -0
- package/dist/commands/deploy-comments.js +8 -2
- package/dist/commands/deploy-events.d.ts +40 -0
- package/dist/commands/deploy-events.js +300 -0
- package/dist/commands/doctor.d.ts +4 -4
- package/dist/commands/doctor.js +2 -2
- package/dist/commands/feedback.js +2 -3
- package/dist/commands/files-browse.js +2 -0
- package/dist/commands/files.js +4 -0
- package/dist/commands/integrations-core.d.ts +11 -0
- package/dist/commands/integrations-core.js +15 -1
- package/dist/commands/keyed-sync-pull.d.ts +12 -0
- package/dist/commands/keyed-sync-pull.js +151 -0
- package/dist/commands/lanes-link.js +2 -2
- package/dist/commands/lanes-loop.d.ts +2 -2
- package/dist/commands/lanes-loop.js +5 -5
- package/dist/commands/lanes-questions.js +1 -1
- package/dist/commands/lanes-stories.js +1 -1
- package/dist/commands/lanes.js +80 -14
- package/dist/commands/library-add.d.ts +5 -2
- package/dist/commands/library-add.js +22 -9
- package/dist/commands/mcp-registration.d.ts +4 -18
- package/dist/commands/mcp-registration.js +9 -29
- package/dist/commands/mesh.d.ts +4 -0
- package/dist/commands/mesh.js +25 -5
- package/dist/commands/pack-install.d.ts +2 -3
- package/dist/commands/pack-install.js +6 -8
- package/dist/commands/rescue.d.ts +3 -2
- package/dist/commands/rescue.js +48 -34
- package/dist/commands/search.d.ts +6 -0
- package/dist/commands/search.js +24 -4
- package/dist/commands/secrets.d.ts +3 -4
- package/dist/commands/secrets.js +3 -20
- package/dist/commands/sources.js +6 -2
- package/dist/commands/sync-core.d.ts +8 -0
- package/dist/commands/sync-core.js +43 -0
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +1830 -1468
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lib/bot/api.d.ts +2 -1
- package/dist/lib/bot/api.js +2 -15
- package/dist/lib/capacity/accounts.d.ts +1 -1
- package/dist/lib/capacity/accounts.js +1 -1
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +0 -2
- package/dist/lib/capacity/collectors/claude-oauth.js +0 -5
- package/dist/lib/capacity/freshness.d.ts +1 -1
- package/dist/lib/capacity/freshness.js +1 -1
- package/dist/lib/capacity/route.js +1 -1
- package/dist/lib/core-utils/delegate-helper-paths.d.ts +26 -0
- package/dist/lib/core-utils/delegate-helper-paths.js +33 -0
- package/dist/lib/daemon/catalog.d.ts +3 -0
- package/dist/lib/daemon/hook-requests.d.ts +1 -1
- package/dist/lib/daemon/hook-requests.js +4 -2
- package/dist/lib/daemon/jq-provision.d.ts +63 -0
- package/dist/lib/daemon/jq-provision.js +155 -0
- package/dist/lib/daemon/lanes-reconcile-guard.d.ts +4 -3
- package/dist/lib/daemon/lanes-reconcile-guard.js +4 -4
- package/dist/lib/daemon/mesh-owner.d.ts +4 -0
- package/dist/lib/daemon/mesh-owner.js +20 -0
- package/dist/lib/daemon/ops/policy.d.ts +3 -0
- package/dist/lib/daemon/ops/policy.js +32 -4
- package/dist/lib/daemon/run.js +17 -22
- package/dist/lib/daemon/server.d.ts +6 -0
- package/dist/lib/daemon/server.js +5 -0
- package/dist/lib/daemon/verified-jq.d.ts +96 -0
- package/dist/lib/daemon/verified-jq.js +337 -0
- package/dist/lib/doctor/checks/jq.js +16 -0
- package/dist/lib/doctor/deep/executor.d.ts +7 -0
- package/dist/lib/doctor/deep/executor.js +1 -1
- package/dist/lib/doctor/deep/parity.js +1 -27
- package/dist/lib/doctor/deep/sandbox.d.ts +2 -2
- package/dist/lib/doctor/deep/sandbox.js +3 -19
- package/dist/lib/doctor/fix/refresh-sync-handoff.js +52 -21
- package/dist/lib/doctor/fixtures/discover.d.ts +2 -0
- package/dist/lib/doctor/fixtures/discover.js +1 -1
- package/dist/lib/doctor/json-output.d.ts +1 -1
- package/dist/lib/doctor/registry.d.ts +6 -7
- package/dist/lib/doctor/registry.js +6 -7
- package/dist/lib/doctor/report.d.ts +9 -10
- package/dist/lib/doctor/report.js +4 -4
- package/dist/lib/environment/work-requirements.d.ts +1 -1
- package/dist/lib/environment/work-requirements.js +1 -1
- 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.js +11 -3
- package/dist/lib/hook-engine/git-stop-config.json +510 -510
- package/dist/lib/hook-engine/native-precompact-compatibility.json +443 -443
- package/dist/lib/hook-engine/native-stop-compatibility.json +359 -359
- package/dist/lib/hot-channels/adapters/meetings.d.ts +1 -16
- package/dist/lib/hot-channels/adapters/meetings.js +3 -28
- package/dist/lib/hot-channels/adapters/slack.d.ts +3 -1
- package/dist/lib/hot-channels/adapters/slack.js +4 -1
- package/dist/lib/hot-channels/contract.d.ts +14 -0
- package/dist/lib/hot-channels/fleet-complete.d.ts +18 -2
- package/dist/lib/hot-channels/fleet-complete.js +29 -4
- package/dist/lib/hot-channels/meeting-source-ref.d.ts +17 -0
- package/dist/lib/hot-channels/meeting-source-ref.js +32 -0
- package/dist/lib/hot-channels/prompts/signals-pass.md +6 -1
- package/dist/lib/hot-channels/run.d.ts +10 -0
- package/dist/lib/hot-channels/run.js +34 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +27 -0
- package/dist/lib/hot-channels/signals-pass.js +57 -2
- package/dist/lib/hot-channels/signals-runtime.js +3 -2
- package/dist/lib/jq/install.d.ts +27 -0
- package/dist/lib/jq/install.js +156 -0
- package/dist/lib/lanes/accounts.js +2 -2
- package/dist/lib/lanes/claude-balance.d.ts +6 -0
- package/dist/lib/lanes/claude-balance.js +124 -0
- package/dist/lib/lanes/grants.js +15 -2
- package/dist/lib/lanes/hq-root.d.ts +1 -1
- package/dist/lib/lanes/hq-root.js +1 -1
- package/dist/lib/lanes/links.d.ts +1 -1
- package/dist/lib/lanes/liveness.d.ts +3 -0
- package/dist/lib/lanes/liveness.js +61 -7
- package/dist/lib/lanes/models.d.ts +1 -1
- package/dist/lib/lanes/models.js +1 -1
- package/dist/lib/lanes/outpost-dispatch.d.ts +1 -1
- package/dist/lib/lanes/outpost-dispatch.js +13 -13
- package/dist/lib/lanes/outpost-pruner-install.js +1 -1
- package/dist/lib/lanes/questions.d.ts +1 -1
- package/dist/lib/lanes/questions.js +2 -2
- package/dist/lib/lanes/spawn.js +4 -6
- package/dist/lib/lanes/store.d.ts +13 -2
- package/dist/lib/lanes/store.js +13 -5
- package/dist/lib/lanes/types.d.ts +7 -7
- package/dist/lib/lanes/types.js +1 -1
- package/dist/lib/lanes/watcher-main.js +1 -1
- package/dist/lib/lanes/watcher.d.ts +1 -1
- package/dist/lib/lanes/watcher.js +1 -1
- package/dist/lib/mesh/live/daemon/doctor.js +7 -1
- package/dist/lib/mesh/live/daemon/install.d.ts +4 -0
- package/dist/lib/mesh/live/daemon/install.js +10 -0
- package/dist/lib/mesh/live/daemon/run.js +17 -0
- package/dist/lib/mesh/live/emit-retry.d.ts +20 -2
- package/dist/lib/mesh/live/emit-retry.js +57 -4
- package/dist/lib/mesh/live/emit.js +25 -4
- package/dist/lib/mesh/live/flush.d.ts +2 -0
- package/dist/lib/mesh/live/flush.js +21 -8
- package/dist/lib/mesh/live/spool.d.ts +9 -1
- package/dist/lib/mesh/live/spool.js +41 -29
- package/dist/lib/onboarding/cli/onboard.js +5 -0
- package/dist/lib/signals/sanitize.d.ts +19 -0
- package/dist/lib/signals/sanitize.js +103 -7
- package/dist/lib/signals/steps/upload.d.ts +40 -1
- package/dist/lib/signals/steps/upload.js +122 -6
- package/dist/lib/sync-core/access-refresh.d.ts +29 -0
- package/dist/lib/sync-core/access-refresh.js +97 -0
- package/dist/lib/sync-core/company-adoption.d.ts +33 -0
- package/dist/lib/sync-core/company-adoption.js +223 -0
- package/dist/lib/sync-core/engine-home.d.ts +1 -0
- package/dist/lib/sync-core/engine-owned.d.ts +13 -0
- package/dist/lib/sync-core/engine-owned.js +38 -0
- package/dist/lib/sync-core/hand-back.d.ts +17 -0
- package/dist/lib/sync-core/hand-back.js +23 -0
- package/dist/lib/sync-core/post-apply-reindex.d.ts +33 -0
- package/dist/lib/sync-core/post-apply-reindex.js +149 -0
- package/dist/lib/sync-core/reconcile.d.ts +10 -0
- package/dist/lib/sync-core/reconcile.js +117 -12
- package/dist/lib/sync-core/rollout-state.d.ts +11 -1
- package/dist/lib/sync-core/rollout-state.js +40 -4
- package/dist/lib/vault-sync-switches.d.ts +14 -0
- package/dist/lib/vault-sync-switches.js +22 -0
- package/dist/lib/windows/jq.d.ts +4 -0
- package/dist/lib/windows/jq.js +10 -39
- package/dist/lib/workers-registry/index.d.ts +1 -1
- package/dist/lib/workers-registry/index.js +8 -12
- package/dist/utils/callback-port-busy.d.ts +2 -2
- package/dist/utils/callback-port-busy.js +2 -2
- package/dist/utils/cli-network-lifecycle.js +1 -0
- package/dist/utils/client-health-contract.d.ts +2 -0
- package/dist/utils/client-health-contract.js +1 -1
- package/dist/utils/client-health.js +1 -9
- package/dist/utils/cognito-config.js +5 -0
- package/dist/utils/cognito-session.d.ts +4 -6
- package/dist/utils/cognito-session.js +4 -24
- package/dist/utils/github-tag-fallback.d.ts +16 -0
- package/dist/utils/github-tag-fallback.js +126 -0
- package/dist/utils/incomplete-install-error.js +1 -11
- package/dist/utils/install-tree-torn.d.ts +11 -0
- package/dist/utils/install-tree-torn.js +1 -1
- package/dist/utils/resident-package-preload.js +2 -1
- package/dist/utils/version-report.d.ts +2 -1
- package/dist/utils/version-report.js +40 -27
- package/docs/anywhere-runtime.md +8 -0
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,80 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [5.345.242] — 2026-11-20
|
|
6
|
+
|
|
7
|
+
- `hq lanes list` no longer reads `~/.hq/work-mesh/spool.jsonl` as one string. An 800 MB spool used to crash with Node's string-length limit; the liveness index now scans the file in 64 KiB chunks.
|
|
8
|
+
|
|
9
|
+
- Fixed (host canary, Codex): `scripts/host-canary.mjs` judges a normal Codex run on the record that answered each event. Inside an HQ root, the tracked `.codex/config.toml` adapter now stands aside for an event the new core marked answered (hq-core-staging `hq-codex-hook-adapter.sh`, hq-hook `host::answered`). So for an event reindex registered to the new core (`native` or `native+shell`), the allow, deny and token evidence now also comes from the new core's record. Before, only config.toml records counted, so the token and the injector parity checks could never both pass while both hooks shared one session ledger (US-021 c4, T5 note 422). Shell-path hooks.json records still never count, and the bash injector replay still judges the injected content.
|
|
10
|
+
- Internal: The credential guard corpus parity check runs as four tests side by side. Each compares every fourth payload, so together they still compare every payload.
|
|
11
|
+
- Fixed (delegate): in transfer mode, `hq core delegate grant` and the bundled `hq-delegate-grant.sh` now also grant the narrower ACL rules under the project that carry no grants. hq-pro's ACL tree lists those only in `masking`, not in `children`, yet each one still overrides the project grant for the keys it covers, so the recipient had no access there while the manifest said "granted". Exact-path and private-folder rules under the project are granted too. A rule the recipient already holds at the same or a higher permission is left alone, and a truncated `masking` list stops the grant instead of leaving rules unchecked.
|
|
12
|
+
- Fixed (delegate): the bundled `hq-delegate-grant.sh` (the fallback when the native delegate route is off) is byte-identical to hq-core-staging main again, with its new `lib/delegate-engine.sh` bundled beside it. Native `hq core delegate grant` gains the same three behaviors. A `prs_` recipient is mapped to its one email through `hq people list` and shared to that email, and the run stops if that email resolves to another person. Where the sync engine owns the company vault, the project and referenced files are pinned in `.hq/pins.json` and the grant waits for the engine's upload instead of running `hq sync push`. The full-folder push is skipped when the vault's dossier files already match, and after a full push the dossier files are pushed again with `--on-conflict overwrite`. Tests run the bundled helper's masking-rule transfer path and each new behavior side by side with native.
|
|
13
|
+
- Fixed (delegate): `hq core delegate publish` no longer runs `hq sync push` (the old uploader) on a company vault the new sync engine owns on this machine. It waits for the engine to upload each published file and checks its sha256 with `hq files cat` (180 s per file, `HQ_DELEGATE_ENGINE_WAIT_SECONDS`), and stops with a message naming the file that did not arrive, the wait it used, and the likely causes (an ignore rule, a symlink, or a path this machine is not granted). On a vault the old sync owns it still pushes, now only the delegation folder and the dossier files instead of the whole project folder. Publish and grant now use the same ownership rule as the sync gate, so a vault the rollout holds keeps the push path, and a failed `hq files cat` no longer counts as an upload of an empty file.
|
|
14
|
+
- Fixed (sync-core): a machine with a `.hqinclude` allowlist at the HQ root keeps every vault on the current sync (held, reason `hqinclude-unsupported`), because the new sync engine does not support the allowlist and would upload everything in scope.
|
|
15
|
+
- Changed (scaffold): the bundled `hq-delegate-grant.sh`, `hq-delegate-publish.sh` and `lib/delegate-engine.sh` are recorded as byte-identical to hq-core-staging again, pinned at the commit where staging took the held-vault and failed-read fixes (hq-core-staging#2070). The script bytes do not change.
|
|
16
|
+
- Tests (delegate): the Windows delegate parity tests pass again. The malformed-ACL grant test expects the `hq sync-core status --json` check that grant gained in this release (10 hq calls, 21 jq calls), and the publish parity tests compare the published manifest's checksum the way the brainstorm publish tests already do: the shell's recorded checksum must match the CRLF file jq.exe wrote, and that file must equal native's LF file once line endings are normalized. The pickup access-refresh test also sets `USERPROFILE`, which is what `os.homedir()` reads on Windows.
|
|
17
|
+
- Internal: The native env-file guard accepts the fixed hq-core guard script (awk reads all content, so the shell guard can no longer exit 141 on SIGPIPE) as well as the released one. Its parity tests now compare against the fixed script.
|
|
18
|
+
- Scheduled jobs on an Outpost report a dead Claude or Codex sign-in once, skip the per-job direct message only after the backend confirms that episode, and run again on the next schedule after that sign-in is renewed. The report opens on that CLI's own sign-in text, or when its credential file is missing. A passed expiry date does not open one. A hold whose credential still reads healthy runs again about an hour later.
|
|
19
|
+
- Fixed (jobs): on an Outpost, a scheduled job whose Claude or Codex credential file is missing no longer writes a sign-in hold unless the backend confirms an episode. Until then each scheduled run keeps today's behavior: it records the run status, runs remediation, sends the per-job direct message and reports the sign-in failure again. `hq core job run --help` now says the per-job direct message is skipped only after a confirmed episode.
|
|
20
|
+
- hq-hook and native stop pull requests move to GitHub-hosted runners when a busy Mac has no load reading, when the route job is cancelled or skipped, or when the Mac queue runs past the pages the route job reads.
|
|
21
|
+
- Fixed an intermittent test failure in the `hq doctor --fix` journal pull tests. The test that stops a background pull at its time limit now waits for the pull to finish exiting before it reads the result, so it no longer fails on slow CI runners. Test-only change; no behavior change for users.
|
|
22
|
+
- Isolate flag snapshot caches before test workers start so tests cannot change the operator's HQ Anywhere fallback setting. Reset fallback state between tests and detect machine fallback changes during each shard.
|
|
23
|
+
- Fixed (sync): a vault whose sync you had turned off in Settings > Sync before it moved to the new sync engine stays off when the vault returns to the current sync, both when the rollout moves it back and when the daemon falls back to the current sync because the installed engine is too old for full sync. Both paths used to turn the switch on for every vault, so a company or personal vault you had turned off started syncing again. Vaults that HQ itself turned off for the move are turned back on as before. If you turn a vault's switch on while the new engine has it, HQ now remembers that and turns the vault back on when it returns. If the settings file cannot be read when a vault moves, HQ leaves that vault off when it returns.
|
|
24
|
+
- Fixed (sync): a vault returning from the new sync engine goes back to the current sync only after its engine has stopped. HQ used to turn the old sync back on while the engine could still be in the middle of a cycle, so both could write to the vault at once. When the daemon falls back to the current sync for an engine that is too old, it now also clears the engine's claim on the vault, so the current sync no longer skips it until the next reconcile.
|
|
25
|
+
- Internal: The Grok Build lifecycle switch-rule test runs as one case per missing event and evaluator set (16 cases), with the same assertions. All 16 setups in one test went past vitest's 5-second limit on loaded CI runners.
|
|
26
|
+
- Updates the bundled HQ Cloud to 6.18.118. The old sync runner now stays off every vault the new sync engine owns: one-shot runs such as `/hq-sync` (`--companies`, `--company`, `--personal`) skip an engine-owned vault and report it as `company-skipped` with reason `new-sync`, and a running runner re-checks ownership before each pass, vault and file, so a vault handed to the engine mid-pass stops at its next file and a vault handed back is synced again without a restart. A vault handed back while its engine process is still running stays skipped until that process exits. `hq rescue` also keeps real folders at release link paths in place.
|
|
27
|
+
- From the same HQ Cloud update: `hq outposts list` now shows your personal Outposts and, grouped by company, the company Outposts you can use (`--company` lists one company's; `--json` without `--company` still lists your personal Outposts only). `hq outposts pull` accepts `--company <slug>` and `--outpost <name|id>` to download from a company Outpost, `hq outposts login-code --company` waits for the Outpost to confirm the sign-in (`--no-wait` skips the wait), and the `hq outposts request --size` help now says the server default is medium.
|
|
28
|
+
- Run the policy gate delivery-regex corpus test in four parallel parts per gate version so the hq-hook PR test shard finishes sooner; every case still runs.
|
|
29
|
+
- Record native PostToolUse master coverage for Codex and Grok on Unix.
|
|
30
|
+
- hq-hook on Windows: guards now compare file paths through one spelled key. A backslash, mixed-separator, verbatim (`\\?\`), uppercase, dot, parent or trailing-dot spelling of a credential, company, core, plans or HQ-root path is now decided the same way as its forward-slash spelling. On macOS and Linux a backslash stays a literal filename character.
|
|
31
|
+
- hq-hook on Windows: a Bash command operand with trailing dots or spaces on a path segment is now compared as the file Windows opens, through the same path key as a file-tool field. `.env.` and `.npmrc.` block like `.env` and `.npmrc`, and a company directory segment with those characters is the directory Windows opens. On macOS and Linux those names stay literal.
|
|
32
|
+
- hq-hook on Windows: a Bash operand whose path cannot be checked, including an unresolved 8.3 short name such as `ENV~1`, is blocked. On a volume where `.env` has that short name, Windows would open `.env`. A tilde that is not an 8.3 name, a flag, and a known-scheme URL stay allowed. On macOS and Linux those bytes stay literal.
|
|
33
|
+
- Fixed: `hq runners create --provider claude --outpost <company Outpost>` no longer fails with `claude_account_balance_target_host_unavailable`. A Claude lane on a company Outpost now uses the Claude account signed in on that Outpost, chosen from the accounts the Outpost reports, instead of this machine's accounts and personal Outposts. `--account auto` on a company Outpost picks from those accounts too, and the lane does not take model or effort from a same-named account on this machine. When no account is ready, the error says whether the accounts are out of quota (with the reset time) or not signed in (with the `hq outposts login` and `login-code` steps for that company and Outpost). `hq runners grant --outpost <company Outpost> --company <slug>` finds a lane that has no local record.
|
|
34
|
+
- Fixed (lanes): `hq lanes create` and lane starts no longer fail with "Unknown host kind" when some other lane record on the machine has a host kind this CLI does not know, such as `microvm`. Hire-grant admission, account selection and host capacity now read lanes the same way `hq lanes list` does: a record that cannot be read is skipped with a warning naming its lane id and field, and the record is left as it is. A hire still stops with `hire_grant_context_invalid` when the unreadable record is a child of the hiring lane and its state is not finished or cannot be read, so the hire grant limit holds.
|
|
35
|
+
- hq-hook: the native credential guard is claimed for PreToolUse on every host and answers every Read and Bash call itself, with no script hash and no hand-back to bash (US-013 c1). A Read of a Windows backslash path to a credential file (for example under `.ssh` or `.aws`) is now refused. Unquoted git path globs stay refused, as before.
|
|
36
|
+
- Fixed (install): the CLI starts again on Node 20.0 to 20.9. The hook-engine coverage gate read its policy files with JSON import attributes, which need Node 20.10, so `hq` failed with a SyntaxError at load (Sentry HQ-CLI-HZ). The files are now read from disk beside the module and copied into the package by the build.
|
|
37
|
+
- Fixed (rescue): rescue and HQ version checks use published release redirects and verified release assets when the GitHub API is unavailable, skipping pending or failed release tags.
|
|
38
|
+
- Commit lookups use git without API quota, and rescue prints one fallback warning per command.
|
|
39
|
+
- The native company scope guard now refuses three command shapes that could write into another company's folder: a zsh `printf` or `print -f` argument of a numeric conversion that is not a plain number (zsh evaluates it as arithmetic, which can run a command named in a variable's value), `busybox` or `toybox` running an applet, and GNU `parallel` (or `sem`) building command lines from its inputs. Listing busybox applets and `parallel --version` still work.
|
|
40
|
+
- Fixed (hooks): the new hook core no longer refuses a personal skill called through the `hq-personal:` name that `hq install-global` adds, or the core `hq-` skill of the same name, on installs that also have a company folder called `personal`. A session locked to a company still cannot load another company's skills.
|
|
41
|
+
- Fixed (search): `hq search --mode lexical` now runs a keyword (BM25) search. qmd calls its BM25 search "lexical", so agents asked for that mode and got an "Unknown search mode" error (Sentry HQ-CLI-J2). `--mode` now also ignores case and surrounding spaces, so `KEYWORD` or ` Hybrid ` work. Other unknown modes still fail with the list of supported modes.
|
|
42
|
+
- Internal: The session-lock fresh-path cost test compares the state-file entry with a fresh hook-cache entry, which allows the same read, instead of a refused entry that does less work. Its bound is scaled with the costlier baseline, from 2.0 to 1.35, with 15 pairs instead of 9, so it still catches every added cost the old check caught. The process-start and registry-request checks are unchanged.
|
|
43
|
+
- Fixed (signals): a bot's scheduled hot-signal-sync job runs the signals pass on the HQ Fleet Executive bot's own login again. The job runs `hq signals run` inside the running bot's HQ Fleet gateway, which sets `HQ_FLEET_HOME` to that bot's profile folder. The pass read that folder as the Fleet home, found no profile for the Executive bot, and fell back to the Claude CLI, so a Codex Executive bot failed with `claude-logged-out-codex-bot` whenever a company had documents waiting. The pass now reads a bot profile folder in `HQ_FLEET_HOME` as the Fleet home two levels up. Manual runs and `hq sources sync` are unchanged.
|
|
44
|
+
- Fixed (signals): `hq signals run` can upload hot-channel meeting signals. Their `source_ref` is `meeting:<id>`, where the id is the meeting bot or transcript id, not a file name. Upload now finds the one transcript in `sources/meetings/` that carries that id, then applies the same audience receipt and audience checks as `sources/meetings/<file>.md`. The signals pass now asks for the start time of the transcript line behind each signal and writes a citation only when that time matches a timed segment in the transcript, using that segment's own start and end. A signal whose transcript or audience receipt has not synced yet is retried on every later run for up to 14 days, without holding back the upload watermark; signals dropped after 14 days are named in the run record. Not being in a meeting's audience is now a permanent skip. The Slack hot channel, which reads only the vault's `sources/slack/` folder, runs without a usable Slack connection and still honours the channels the person picked on their Slack connections, including a connection that was later revoked.
|
|
45
|
+
- New sync: company skills, commands and workers that arrive or are removed through the new sync engine are now registered. The `sync-core` reconcile (every 10 minutes) compares the skills, commands and `worker.yaml` files under each vault the engine owns with the last run and, only when they differ, runs the same reindex the old sync ran after a pull. Before, a skill delivered by the new sync had no `<company>:<skill>` wrapper until someone ran `hq reindex`, and a removed skill left a dead wrapper. A reindex that cannot run is tried again on each reconcile and its warning is logged once. `hq sync pull` and `hq sync now` on a vault the new sync engine owns now say that the new sync is handling it and point to `hq sync-core status`; before, they said sync was off and told the user to turn the switch back on, which would have restarted the old sync on that vault. The exit code (3) is unchanged.
|
|
46
|
+
- Fixed (sync): a company you join on a computer that uses the new sync engine now gets set up by the engine itself. `hq daemon` (the `sync-core` unit, every 10 minutes) creates the company's folder under `companies/` and adds its `cloud_uid`, `name` and `bucket_name` entry to the companies manifest when the rollout switch is on for that company, then the engine downloads its files. Before, only a pass of the old sync wrote the folder and the entry, so with the HQ desktop app closed, or with every other vault already on the new engine, the joined company was never synced and nothing said so. An entry that is already in the manifest is never changed, the new entry is appended so the file's comments stay, and the write is retried if another writer changed the manifest meanwhile. A folder that already has files but no manifest entry is left alone with a warning, and no empty folder is created for a company the old sync or the engine has synced on this computer before. Nothing is set up on Windows, Outposts and agent machines, for a vault in `~/.hq/sync-core/skip.json`, for a company whose sync switch is off, or when the rollout switch is off (the old sync still handles the join there). Cost: one flag read per run for each membership with no local folder, and one company lookup while such a company has the switch on.
|
|
47
|
+
- Fixed (sync): when the new sync engine owns a company vault on this machine, commands that change what you can see in it now ask that engine to read your access at once, instead of waiting for its access re-check (up to 24 hours for some re-grants). This covers `hq files share --with`, `hq files unshare`, `hq files get` (when it pins), accepting an invite with `hq onboard join` (and a resumed join), and `hq core delegate pickup` when it records a pickup. The CLI writes `access-refresh.json` in that vault's engine home only; a failed write never fails the command and is logged only with `--verbose` or `HQ_DEBUG=1`.
|
|
48
|
+
- Handoff archive checks now call `hq runners list`, and additional runner diagnostics and command documentation use the canonical `hq runners` name. The `hq lanes` compatibility alias remains available.
|
|
49
|
+
- The new hook core now answers the repository merge hold (`lanes-repo-merge-hold`) itself on Claude Code and Codex, outside Windows. Its decisions match the released hook and that hook's own test suite. Grok, the fleet runtimes and Windows still run the shell hook.
|
|
50
|
+
- The native company scope guard now refuses three command shapes the released shell guard refuses: an `xargs` with an option the guard does not know or a program named by a path, a shell function after `set -a` (which exports it to child shells), and a zsh modifier such as `$p:h` on a variable whose value is known.
|
|
51
|
+
- hq-hook: `hq-hook run --host codex PreToolUse` now refuses a Codex `apply_patch`, `Edit` or `Write` into `core/` with the released Codex adapter's own message (`Edits to core/ are denied by hq-codex-hook-adapter.sh (<path>).`, exit 2), unless `HQ_BYPASS_CORE_PROTECT` is `1`, `true`, `TRUE`, `yes` or `YES`, and refuses an edit of a dotenv file whose new content it cannot read, or a rename into one, with the adapter's `Edit to dotenv file <path> denied by hq-codex-hook-adapter.sh: <why>` line. `hq-hook run --host grok PreToolUse` now binds a Grok subagent's company on its first tool call, as the adapter's `bind_subagent_once` did; a bind it cannot decide binds nothing and refuses the call. `codex-adapter:PreToolUse` is claimed on Codex and `grok-adapter:PreToolUse` on Grok (`hq-hook capabilities --json`), with a parity test against the v16.0.50 adapters (US-050 c1). PreToolUse stays on the old path until `master-hook:PreToolUse` and every registry hook are claimed.
|
|
52
|
+
- Internal: `hq-hook` now claims the local bot runtime's SubagentStop natively (`SubagentStop@fleet-local`: `fleet-local-adapter:SubagentStop` and `master-hook:SubagentStop`). master-hook's own SubagentStop work under the hq-fleet-local v0.4.33 adapter (session bind, twin dedupe, timeout journal) is done by `lifecycle_master`, at parity with the released adapter running the real master-hook. The adapter's `.claude/settings.json` SubagentStop commands go to the HQ daemon on the `fleet-local-settings` request note, as SessionEnd's do, and the daemon accepts `SubagentStop` on that note. A SubagentStop hook the claim does not name, a payload with no session id and a pinned-engine exec entry are refused natively. Hosted agents (`agents-v2`) are unchanged. The event still registers on the shell adapter until an engine reports `lifecycle-dispatch`.
|
|
53
|
+
|
|
54
|
+
## [5.345.241] — 2026-11-20
|
|
55
|
+
- The daemon's company access check now runs only with a jq that passes a version and behavior check. A homemade or wrapper `jq` first on the daemon's PATH used to block every call with "invalid agent_id", and one that echoed its input could let calls into another company's folder through. The daemon now picks a working jq, installs its own checksum-verified jq 1.8.2 under `~/.hq/daemon/tools` when the machine has none, and blocks with a plain reason while no working jq exists. Policy checks also pass an empty agent identity so the authorizer no longer reads agent fields with jq. `hq doctor` now fails a jq whose `--version` is not `jq-1.x`. Windows hook setup and doctor repair share the same checksum-verified download installer with daemon provisioning; managed installs reject symlink destinations and unsafe writable directories.
|
|
56
|
+
- `hq core delegate` now prints paths the way the hq-core helpers do on every platform: the HQ root followed by forward-slash segments. This covers the secrets schema source in the plan and the missing-name error, the repo directory in `hq core delegate repo`'s "not a git repository" error and push plan, and `board.json` in `hq core delegate transfer`'s invalid-board error. Before this fix, Windows printed backslashes and did not match the helpers. `hq core delegate repo` also uses an absolute `repo.path` (POSIX or a Windows drive path) as-is, as `hq-delegate-repo.sh` does, instead of looking for it under the HQ root.
|
|
57
|
+
- `hq core delegate secrets` (and the secrets step of `hq core delegate run`) now applies the same safeguards as the hq-core helper. It reads secret names from `--env-schema` first, then the project's `.env.schema`, then `prd.json` `metadata.secrets`, and uses the repo's `.env.schema` only when the project declares nothing. In that case the plan names the repo schema and warns. A `metadata.secrets` entry that is not a secret name, a missing `--env-schema` file, or an unreadable schema now stops the step with nothing granted. Before sharing anything, every name is checked against `hq secrets list`; if any name is missing, nothing is shared. Agent and person-uid recipients share through the `grantPrincipal` the grant step recorded, and are refused when there is none.
|
|
58
|
+
- `hq core delegate grant` in transfer mode now grants the same permission on every narrower ACL rule under the project prefix (for example `projects/<name>/design/*`) and verifies each one. Before this change, the recipient kept the older, narrower permission there while the manifest said "granted". `hq core delegate transfer` now uses the delegation id as the Work Mesh session id when no session id is set, which ends the SESSION_OWNER_MISMATCH failures from the shared "delegate" session. It also resolves an email recipient to a person uid and moves project ownership and open stories with `hq mesh project reassign`, recording `confirmed`, `not-registered` or `unconfirmed` the same way the hq-core helper does.
|
|
59
|
+
- Added `hq deploy events enable|list|reply|watch` for the owner side of site events on a deployed app: turn events on or off, list them, reply to a visitor or mark an event handled, and watch for new events as one JSON line each. The watcher keeps a cursor file so a restart does not repeat events, and it signs in again on every poll. Each command takes `--company <slug>` or `--personal`. `hq deploy comments list` now accepts `--personal` to read comments on a personal app. These replace the `/deploy` skill's own copies of these API calls (US-033).
|
|
60
|
+
- When `hq feedback update` cannot store a PR or lane link, the error no longer says the server may not support work links; the server has supported them since October 2026. The error still reports the server's message and the ticket's current state.
|
|
61
|
+
- Run Grok SubagentStop through the native event dispatcher with parity checks for normal output and session bookkeeping; keep opt-in trace diagnostics visible.
|
|
62
|
+
- Give the macOS Claude host canary disposable sign-in directories and report sign-in failures and unrelated sessions separately.
|
|
63
|
+
- Read native Stop inputs through checked Windows handles while keeping store writes disabled; preserve checkpoint blocks and refuse unreadable registries.
|
|
64
|
+
- Refuse untrusted Windows DACL write/delete grants and unsafe session inputs; evaluate Stop against checked session bytes even if its file is replaced.
|
|
65
|
+
- Permit default Windows ancestor create-child grants while rejecting replacement rights; respect ordered DACL denies and isolate Windows fixtures from shared CI scratch permissions.
|
|
66
|
+
- hq-hook on Windows: credential checks no longer hang on drive paths when realpath is unavailable; unresolved paths are refused and credential blocking stays on. Drive prefixes survive path normalization, settings scripts resolve under verbatim roots, and the six Windows unit failures are fixed.
|
|
67
|
+
- Allow read-only `hq sync pull` with `HQ_API_KEY`, an explicit company UID and trusted `--company-slug`, without a Cognito session. Validate complete inventory before staging downloads and preserve unlisted local files.
|
|
68
|
+
- `hq mesh daemon status` reports the mesh service as running when `hq daemon` runs it, on macOS, Linux and Windows, instead of saying the retired `ai.getindigo.hq-mesh-daemon` unit is not installed. It still reports the retired unit on an install where `hq daemon` does not run the mesh service.
|
|
69
|
+
- In direct mode the Work Mesh service now writes one log line when a delivery cycle finds queued events and claims none of them, naming the reason (HQ Anywhere switched off by the operator, or HQ Anywhere reading as off for the person or machine with no queued event from a company-bound session) and the queued count. The line is written once per reason and again after a cycle that delivered something, and the reason is also kept in the service's last flush result.
|
|
70
|
+
- Work Mesh live reporting no longer deletes queued events when a queue file cannot be read. A claim file the flush cannot read, or whose events cannot be put back on the spool, is now kept and retried on the next flush, and claim files are read in chunks so a very large one still loads. `hq mesh emit` and the emit retry path no longer replace `emit-retry.jsonl` after a failed read: unsent events are appended to it, the failure is logged, and `hq mesh daemon doctor` reports the file as unreadable.
|
|
71
|
+
- Make the `hq doctor --fix` refresh spawn lock takeover atomic, so two processes can no longer both take over a dead holder's lock.
|
|
72
|
+
- Drain stdin in the skill command script test fixture so the shell parity check gets the fixture's result.
|
|
73
|
+
- Stop manual sync with a clear error when the sync engine rollout state is unreadable or invalid, protecting vaults from being synced by the wrong engine.
|
|
74
|
+
- `hq sync pull --all`, `hq sync push --all` and the single-company sync commands skip a company whose sync scope lookup fails, with a short message naming the company and the error class, instead of syncing it unscoped. Other companies keep syncing, and the run still exits 1. A lookup refused for sign-in reasons shows the sign-in fix. This takes @indigoai-us/hq-cloud 6.18.117, whose scope resolver now fails closed instead of answering "all" on a failed lookup.
|
|
75
|
+
- Fixed Outpost lane commands and generated worktree-pruner services to call `hq runners`, while retaining the `hq lanes` compatibility alias and scheduled-run classification for pruner timers.
|
|
76
|
+
- Windows hook acceptance checks can load Beaker trial reports for the exact tested commit. A submitted report now fails on missing acceptance evidence (corpus, both architectures, signed-off engine timings) and prints failed native event outcomes; only an absent report stays pending.
|
|
77
|
+
- Preserve literal backslashes and quotes in generated worker registry paths and metadata.
|
|
78
|
+
|
|
5
79
|
## [5.345.238] — 2026-11-19
|
|
6
80
|
- Publish the warm CLI test fixture atomically before executing it on Unix.
|
|
7
81
|
- Internal: The hq-hook PR test shards run under cargo-nextest, one process per test across all cores.
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
# 3. read each grant back with hq files acl and match grantee + permission
|
|
18
18
|
# 4. advance manifest status building -> granted, stamping verifiedAt
|
|
19
19
|
#
|
|
20
|
+
# When the new sync engine owns the company vault on this machine, the CLI
|
|
21
|
+
# refuses `hq sync push`. Step 1 is then skipped, and after the grants the
|
|
22
|
+
# helper waits for the engine to upload the dossier and referenced files
|
|
23
|
+
# (lib/delegate-engine.sh) before it advances the status.
|
|
24
|
+
#
|
|
20
25
|
# Direct ACL grants ONLY — this helper never mints a share-session URL
|
|
21
26
|
# (policy hq-delegate-never-inlines-secrets-or-share-urls).
|
|
22
27
|
#
|
|
@@ -29,8 +34,9 @@ set -euo pipefail
|
|
|
29
34
|
|
|
30
35
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
31
36
|
HQ_ROOT="${HQ_ROOT:-$(cd "$SCRIPT_DIR/../.." && pwd)}"
|
|
37
|
+
. "$SCRIPT_DIR/lib/delegate-engine.sh"
|
|
32
38
|
|
|
33
|
-
usage() { sed -n '3,
|
|
39
|
+
usage() { sed -n '3,30p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; }
|
|
34
40
|
die() { echo "hq-delegate-grant: $*" >&2; exit 1; }
|
|
35
41
|
|
|
36
42
|
command -v jq >/dev/null 2>&1 || die "jq is required but not installed"
|
|
@@ -85,6 +91,7 @@ PROJECT="$(jq -r '.project.name // empty' "$MANIFEST" | tr -d '\r')"
|
|
|
85
91
|
PRINCIPAL="$(jq -r '.to.principal // empty' "$MANIFEST" | tr -d '\r')"
|
|
86
92
|
DISPLAY="$(jq -r '.to.displayName // .to.principal // empty' "$MANIFEST" | tr -d '\r')"
|
|
87
93
|
STATUS="$(jq -r '.status // empty' "$MANIFEST" | tr -d '\r')"
|
|
94
|
+
MODE="$(jq -r '.mode // empty' "$MANIFEST" | tr -d '\r')"
|
|
88
95
|
[ -n "$COMPANY" ] || die "manifest has no company"
|
|
89
96
|
[ -n "$PROJECT" ] || die "manifest has no project.name"
|
|
90
97
|
[ -n "$PRINCIPAL" ] || die "manifest has no to.principal"
|
|
@@ -138,13 +145,42 @@ if [ -n "$BAD" ]; then
|
|
|
138
145
|
die "prefix violates the hq-files prefix conventions (must be company-relative folder form ending in '/'): $BAD"
|
|
139
146
|
fi
|
|
140
147
|
|
|
148
|
+
# --- person recipients named by personUid ------------------------------------
|
|
149
|
+
# `hq people resolve` matches names and emails only (a prs_ uid returns
|
|
150
|
+
# not_found), and `hq files share --with` accepts only email / grp_ / @all.
|
|
151
|
+
# Map the prs_ uid to its email through the structured people roster, then
|
|
152
|
+
# resolve and share by that email. The authoritative membership resolve below
|
|
153
|
+
# must return this exact personUid, or the run stops.
|
|
154
|
+
RESOLVE_KEY="$PRINCIPAL"
|
|
155
|
+
case "$PRINCIPAL" in
|
|
156
|
+
prs_*)
|
|
157
|
+
PEOPLE_JSON="$(hq people list --company "$COMPANY" --json \
|
|
158
|
+
| awk 'started {print; next} /^[[:space:]]*[{[]/ {started=1; print}')" \
|
|
159
|
+
|| die "could not list people to map personUid $PRINCIPAL to an email; set to.principal to the recipient's email and re-run"
|
|
160
|
+
PRS_EMAILS="$(printf '%s' "$PEOPLE_JSON" | jq -r --arg uid "$PRINCIPAL" '
|
|
161
|
+
if type == "array" then . else (.people // error("unexpected people list shape")) end
|
|
162
|
+
| [.[] | select(.personUid == $uid) | .email
|
|
163
|
+
| select(type == "string" and length > 0) | ascii_downcase] | unique | .[]
|
|
164
|
+
' | tr -d '\r')" \
|
|
165
|
+
|| die "people list returned unexpected JSON while mapping $PRINCIPAL; set to.principal to the recipient's email and re-run"
|
|
166
|
+
PRS_EMAIL_COUNT="$(printf '%s' "$PRS_EMAILS" | grep -c . || true)"
|
|
167
|
+
[ "$PRS_EMAIL_COUNT" -eq 1 ] \
|
|
168
|
+
|| die "personUid $PRINCIPAL maps to $PRS_EMAIL_COUNT emails in company '$COMPANY' (need exactly 1); set to.principal to the recipient's email and re-run"
|
|
169
|
+
RESOLVE_KEY="$PRS_EMAILS"
|
|
170
|
+
GRANT_PRINCIPAL="$PRS_EMAILS"
|
|
171
|
+
;;
|
|
172
|
+
esac
|
|
173
|
+
|
|
141
174
|
# --- plan (always printed; the only output without --yes) --------------------
|
|
142
175
|
|
|
143
176
|
echo "Delegation grant plan — company '$COMPANY', recipient '$PRINCIPAL':"
|
|
144
|
-
|
|
177
|
+
case "$PRINCIPAL" in
|
|
178
|
+
prs_*) echo " 0. Person recipient: personUid $PRINCIPAL maps to $GRANT_PRINCIPAL; grants are shared to that email" ;;
|
|
179
|
+
esac
|
|
180
|
+
if [ "${PRINCIPAL#agt_}" != "$PRINCIPAL" ]; then
|
|
145
181
|
echo " 0. Agent recipient: grants flow through group $GRANT_PRINCIPAL (created if absent, containing exactly $DISPLAY)"
|
|
146
182
|
fi
|
|
147
|
-
echo " 1. Push companies/$COMPANY/projects/$PROJECT/ to the vault (on-conflict keep)"
|
|
183
|
+
echo " 1. Push companies/$COMPANY/projects/$PROJECT/ to the vault (on-conflict keep); where the sync engine owns the vault, pin it in .hq/pins.json and wait for its upload after the grants instead"
|
|
148
184
|
jq -r '.vaultPrefixes[] | " 2. Grant \(.permission) on \(.prefix) — \(.reason // "")"' "$MANIFEST" | tr -d '\r'
|
|
149
185
|
WRITE_PREFIXES="$(jq -r '.vaultPrefixes[] | select(.permission == "write") | .prefix' "$MANIFEST" | tr -d '\r')"
|
|
150
186
|
if [ -n "$WRITE_PREFIXES" ]; then
|
|
@@ -165,10 +201,53 @@ fi
|
|
|
165
201
|
# on the prefix and silently misses the file. Push every referenced
|
|
166
202
|
# company-local knowledge/policy path alongside the dossier.)
|
|
167
203
|
|
|
168
|
-
|
|
169
|
-
|
|
204
|
+
ENGINE_OWNED=0
|
|
205
|
+
if hq_delegate_engine_owns_vault "$COMPANY"; then ENGINE_OWNED=1; fi
|
|
170
206
|
|
|
171
|
-
|
|
207
|
+
# Skip the full-folder push when the vault already holds this project: a large
|
|
208
|
+
# project re-walks thousands of unchanged files and can exceed the foreground
|
|
209
|
+
# timeout. Compare the dossier files' checksums local vs vault first; any
|
|
210
|
+
# mismatch, missing file, or unreadable vault copy falls back to the full push.
|
|
211
|
+
vault_has_project() {
|
|
212
|
+
local f lp remote_hash local_hash compared=0
|
|
213
|
+
for f in prd.json README.md brainstorm.md; do
|
|
214
|
+
lp="$HQ_ROOT/companies/$COMPANY/projects/$PROJECT/$f"
|
|
215
|
+
[ -f "$lp" ] || continue
|
|
216
|
+
remote_hash="$(hq files cat "projects/$PROJECT/$f" --company "$COMPANY" 2>/dev/null | { sha256sum 2>/dev/null || shasum -a 256; } | cut -d ' ' -f1)" || return 1
|
|
217
|
+
local_hash="$({ sha256sum "$lp" 2>/dev/null || shasum -a 256 "$lp"; } | cut -d ' ' -f1)"
|
|
218
|
+
[ -n "$remote_hash" ] && [ "$remote_hash" = "$local_hash" ] || return 1
|
|
219
|
+
compared=$((compared + 1))
|
|
220
|
+
done
|
|
221
|
+
[ "$compared" -gt 0 ]
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if [ "$ENGINE_OWNED" -eq 1 ]; then
|
|
225
|
+
echo "hq-delegate-grant: the sync engine owns the '$COMPANY' vault on this machine — no push; pinning the project and referenced files so the engine uploads them"
|
|
226
|
+
PIN_PATHS=("projects/$PROJECT/")
|
|
227
|
+
while IFS= read -r kpath; do
|
|
228
|
+
[ -n "$kpath" ] && PIN_PATHS+=("$kpath")
|
|
229
|
+
done < <(jq -r --arg co "$COMPANY" \
|
|
230
|
+
'((.knowledge // []) + (.policies // []))[] | select(startswith("companies/" + $co + "/")) | ltrimstr("companies/" + $co + "/")' \
|
|
231
|
+
"$MANIFEST" | tr -d '\r')
|
|
232
|
+
hq_delegate_engine_pin "$HQ_ROOT" "$COMPANY" "${PIN_PATHS[@]}" \
|
|
233
|
+
|| die "could not add the project to $HQ_ROOT/.hq/pins.json for the sync engine"
|
|
234
|
+
elif vault_has_project; then
|
|
235
|
+
echo "hq-delegate-grant: vault already has companies/$COMPANY/projects/$PROJECT/ (dossier checksums match) — skipping full-folder push"
|
|
236
|
+
else
|
|
237
|
+
hq sync push "companies/$COMPANY/projects/$PROJECT/" --company "$COMPANY" --on-conflict keep \
|
|
238
|
+
|| die "vault push failed for companies/$COMPANY/projects/$PROJECT/"
|
|
239
|
+
# on-conflict keep drops the delegator's fresh local edits when the vault copy
|
|
240
|
+
# differs. The delegator owns the dossier, so push these files again with
|
|
241
|
+
# overwrite, and fail the step if one cannot be pushed.
|
|
242
|
+
for dossier_file in prd.json README.md brainstorm.md; do
|
|
243
|
+
if [ -f "$HQ_ROOT/companies/$COMPANY/projects/$PROJECT/$dossier_file" ]; then
|
|
244
|
+
hq sync push "companies/$COMPANY/projects/$PROJECT/$dossier_file" --company "$COMPANY" --on-conflict overwrite \
|
|
245
|
+
|| die "vault push failed for dossier file companies/$COMPANY/projects/$PROJECT/$dossier_file"
|
|
246
|
+
fi
|
|
247
|
+
done
|
|
248
|
+
fi
|
|
249
|
+
|
|
250
|
+
[ "$ENGINE_OWNED" -eq 1 ] || jq -r --arg co "$COMPANY" \
|
|
172
251
|
'((.knowledge // []) + (.policies // []))[] | select(startswith("companies/" + $co + "/"))' \
|
|
173
252
|
"$MANIFEST" | tr -d '\r' | while IFS= read -r kpath; do
|
|
174
253
|
if [ -e "$HQ_ROOT/$kpath" ]; then
|
|
@@ -181,7 +260,7 @@ done
|
|
|
181
260
|
|
|
182
261
|
# --- 1b. agent recipients: ensure the delegation group exists + contains them
|
|
183
262
|
|
|
184
|
-
if [ "$
|
|
263
|
+
if [ "${PRINCIPAL#agt_}" != "$PRINCIPAL" ]; then
|
|
185
264
|
# Group creation and add are idempotent-tolerated; confirm that the complete
|
|
186
265
|
# member list is exactly this agent before any file ACL is shared.
|
|
187
266
|
hq groups create "$GRANT_PRINCIPAL" --name "Delegation: $DISPLAY" --company "$COMPANY" \
|
|
@@ -206,13 +285,20 @@ case "$GRANT_PRINCIPAL" in
|
|
|
206
285
|
@all) EXPECTED_TYPE=company-wide; EXPECTED_ID="" ;;
|
|
207
286
|
*)
|
|
208
287
|
RESOLVE_RC=0
|
|
209
|
-
RESOLVED="$(hq people resolve "$
|
|
288
|
+
RESOLVED="$(hq people resolve "$RESOLVE_KEY" --company "$COMPANY" --json --membership-only)" || RESOLVE_RC=$?
|
|
210
289
|
if printf '%s' "$RESOLVED" | jq -e '.status == "found" and (.person.personUid | type == "string") and (.person.companyUid | type == "string")' >/dev/null; then
|
|
211
290
|
[ "$RESOLVE_RC" -eq 0 ] || die "recipient resolution failed"
|
|
212
291
|
EXPECTED_TYPE=person
|
|
213
292
|
EXPECTED_ID="$(printf '%s' "$RESOLVED" | jq -r '.person.personUid' | tr -d '\r')"
|
|
214
293
|
EXPECTED_COMPANY="$(printf '%s' "$RESOLVED" | jq -r '.person.companyUid' | tr -d '\r')"
|
|
294
|
+
case "$PRINCIPAL" in
|
|
295
|
+
prs_*) [ "$EXPECTED_ID" = "$PRINCIPAL" ] \
|
|
296
|
+
|| die "personUid $PRINCIPAL mapped to $RESOLVE_KEY, but membership resolves that email to $EXPECTED_ID; set to.principal to the recipient's email and re-run" ;;
|
|
297
|
+
esac
|
|
215
298
|
elif printf '%s' "$RESOLVED" | jq -e '.status == "not_found"' >/dev/null; then
|
|
299
|
+
case "$PRINCIPAL" in
|
|
300
|
+
prs_*) die "personUid $PRINCIPAL ($RESOLVE_KEY) is not an active member of company '$COMPANY'" ;;
|
|
301
|
+
esac
|
|
216
302
|
case "$PRINCIPAL" in *@*) EXPECTED_TYPE=email; EXPECTED_ID="$(printf '%s' "$PRINCIPAL" | tr '[:upper:]' '[:lower:]' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')" ;; *) die "unresolved recipient" ;; esac
|
|
217
303
|
else
|
|
218
304
|
die "authoritative recipient lookup failed; update hq-cli if --membership-only is unsupported"
|
|
@@ -261,6 +347,61 @@ while [ "$i" -lt "$PREFIX_COUNT" ]; do
|
|
|
261
347
|
fi
|
|
262
348
|
done
|
|
263
349
|
[ "$landed" -eq 1 ] || die "grant outcome unconfirmed for $PRINCIPAL on $PFX; retain this manifest and resume"
|
|
350
|
+
# Full-transfer mode: a more specific rule under the project prefix (for
|
|
351
|
+
# example projects/<name>/design/* or projects/<name>/design) outranks the
|
|
352
|
+
# root grant, so the recipient would keep the narrower permission there, or
|
|
353
|
+
# have none at all. Grant the same permission on every such rule and verify
|
|
354
|
+
# each one. The ACL tree lists rules that carry grants as .children and
|
|
355
|
+
# rules with no grants only as .masking, so both are read; a truncated
|
|
356
|
+
# masking list stops the grant rather than leave an unseen rule ungranted.
|
|
357
|
+
# A rule the recipient already holds at this permission or higher is left
|
|
358
|
+
# as it is. Only rules under the project prefix are considered, so the
|
|
359
|
+
# outside-project check below is defensive.
|
|
360
|
+
if [ "$MODE" = "transfer" ]; then
|
|
361
|
+
case "$PFX" in "projects/$PROJECT/"*)
|
|
362
|
+
if printf '%s' "$AFTER" | jq -e '.maskingTruncated == true' >/dev/null 2>&1; then
|
|
363
|
+
die "the ACL tree for $PFX lists too many overriding rules to check; grant them by hand, then resume"
|
|
364
|
+
fi
|
|
365
|
+
CHILD_RULES="$(printf '%s' "$AFTER" | jq -r --arg pfx "$PFX" --arg root "$ACL_PATTERN" \
|
|
366
|
+
--arg id "$EXPECTED_ID" --arg type "$EXPECTED_TYPE" --arg perm "$PERM" '
|
|
367
|
+
def rank: if . == "admin" then 3 elif . == "write" then 2 elif . == "read" then 1 else 0 end;
|
|
368
|
+
def holds: .granteeType == $type and .granteeId == $id and (((.permission // "") | rank) >= ($perm | rank));
|
|
369
|
+
def under: type == "string" and startswith($pfx) and . != $root;
|
|
370
|
+
( [ (.children // [])[] | select(.sourcePrefix | under) | {p: .sourcePrefix, held: holds} ]
|
|
371
|
+
+ [ (.masking // [])[] | select(.path | under) | {p: .path, held: ((.grantees // []) | any(holds))} ] )
|
|
372
|
+
| group_by(.p) | map({p: .[0].p, held: any(.[]; .held)}) | .[]
|
|
373
|
+
| (if .held then "held" else "grant" end) + "\t" + .p' | tr -d '\r')"
|
|
374
|
+
# One rule per line, read whole: a folder name with a space or a glob
|
|
375
|
+
# character must stay one pattern. Word-splitting it would grant on a
|
|
376
|
+
# path outside the project. fd 3 keeps the hq calls off the list.
|
|
377
|
+
while IFS="$(printf '\t')" read -r CHILD_STATE CHILD <&3; do
|
|
378
|
+
[ -n "$CHILD" ] || continue
|
|
379
|
+
case "$CHILD" in "projects/$PROJECT/"*) ;; *) die "more specific rule $CHILD is outside projects/$PROJECT/" ;; esac
|
|
380
|
+
if [ "$CHILD_STATE" = held ]; then
|
|
381
|
+
echo "hq-delegate-grant: $PRINCIPAL already holds $PERM or higher on more specific rule $CHILD"
|
|
382
|
+
continue
|
|
383
|
+
fi
|
|
384
|
+
CHILD_RC=0
|
|
385
|
+
hq files share "$CHILD" --with "$GRANT_PRINCIPAL" --permission "$PERM" --company "$COMPANY" || CHILD_RC=$?
|
|
386
|
+
[ "$CHILD_RC" -eq 0 ] || echo "hq-delegate-grant: share reported an error on $CHILD; checking exact grant" >&2
|
|
387
|
+
child_landed=0
|
|
388
|
+
for delay in 0 1 2; do
|
|
389
|
+
[ "$delay" -eq 0 ] || sleep "$delay"
|
|
390
|
+
if CHILD_AFTER="$(read_acl "$CHILD")" && printf '%s' "$CHILD_AFTER" | jq -e \
|
|
391
|
+
--arg id "$EXPECTED_ID" --arg type "$EXPECTED_TYPE" --arg perm "$PERM" \
|
|
392
|
+
'.exists and any(.direct[]; .granteeType == $type and .granteeId == $id and .permission == $perm)' >/dev/null; then
|
|
393
|
+
child_landed=1
|
|
394
|
+
break
|
|
395
|
+
fi
|
|
396
|
+
done
|
|
397
|
+
[ "$child_landed" -eq 1 ] || die "grant outcome unconfirmed for $PRINCIPAL on more specific rule $CHILD; retain this manifest and resume"
|
|
398
|
+
echo "hq-delegate-grant: verified $PERM on more specific rule $CHILD for $PRINCIPAL"
|
|
399
|
+
done 3<<EOF_CHILDREN
|
|
400
|
+
$CHILD_RULES
|
|
401
|
+
EOF_CHILDREN
|
|
402
|
+
;;
|
|
403
|
+
esac
|
|
404
|
+
fi
|
|
264
405
|
TMP_MANIFEST="$(mktemp)"
|
|
265
406
|
jq --argjson i "$i" --arg now "$NOW" --arg id "$EXPECTED_ID" --arg type "$EXPECTED_TYPE" \
|
|
266
407
|
--arg company "$EXPECTED_COMPANY" --argjson rc "$SHARE_RC" '
|
|
@@ -271,6 +412,27 @@ while [ "$i" -lt "$PREFIX_COUNT" ]; do
|
|
|
271
412
|
i=$((i + 1))
|
|
272
413
|
done
|
|
273
414
|
|
|
415
|
+
# --- 3b. engine-owned vault: wait for the engine's upload ---------------------
|
|
416
|
+
# The pins above bring the files into the engine's scope; confirm the exact
|
|
417
|
+
# bytes of the dossier and every referenced company file before reporting success.
|
|
418
|
+
|
|
419
|
+
if [ "$ENGINE_OWNED" -eq 1 ]; then
|
|
420
|
+
{
|
|
421
|
+
for f in prd.json README.md brainstorm.md; do
|
|
422
|
+
[ -f "$HQ_ROOT/companies/$COMPANY/projects/$PROJECT/$f" ] && echo "companies/$COMPANY/projects/$PROJECT/$f"
|
|
423
|
+
done
|
|
424
|
+
jq -r --arg co "$COMPANY" \
|
|
425
|
+
'((.project.dossier // []) + (.knowledge // []) + (.policies // []))[] | select(startswith("companies/" + $co + "/"))' \
|
|
426
|
+
"$MANIFEST" | tr -d '\r'
|
|
427
|
+
} | sort -u | while IFS= read -r kpath; do
|
|
428
|
+
[ -f "$HQ_ROOT/$kpath" ] || continue
|
|
429
|
+
expected="$(hq_delegate_sha256 < "$HQ_ROOT/$kpath")"
|
|
430
|
+
hq_delegate_wait_for_cloud "$COMPANY" "${kpath#"companies/$COMPANY/"}" "$expected" \
|
|
431
|
+
|| die "the sync engine has not uploaded $kpath after $(hq_delegate_engine_wait_seconds)s ($HQ_DELEGATE_ENGINE_WAIT_CAUSES); check 'hq sync-core status', then re-run (grants are idempotent)"
|
|
432
|
+
done
|
|
433
|
+
echo "hq-delegate-grant: the sync engine uploaded the dossier; vault bytes match"
|
|
434
|
+
fi
|
|
435
|
+
|
|
274
436
|
# --- 4. advance manifest status ----------------------------------------------
|
|
275
437
|
|
|
276
438
|
TMP_MANIFEST="$(mktemp)"
|
|
@@ -11,6 +11,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
11
11
|
HQ_ROOT="${HQ_ROOT:-$(cd "$SCRIPT_DIR/../.." && pwd)}"
|
|
12
12
|
. "$SCRIPT_DIR/lib/secret-patterns.sh"
|
|
13
13
|
. "$SCRIPT_DIR/lib/delegate-brainstorm.sh"
|
|
14
|
+
. "$SCRIPT_DIR/lib/delegate-engine.sh"
|
|
14
15
|
die() { echo "hq-delegate-publish: $*" >&2; exit 1; }
|
|
15
16
|
[ "${1:-}" = --manifest ] && [ -f "${2:-}" ] || die 'usage: --manifest <path>'
|
|
16
17
|
MANIFEST="$2"
|
|
@@ -100,14 +101,33 @@ atomic_copy "$STAGE/manifest.json" "$DEST/manifest.json"
|
|
|
100
101
|
atomic_copy "$STAGE/manifest.json" "$MANIFEST"
|
|
101
102
|
# keep may preserve stale canonical content. Read-back must catch that instead
|
|
102
103
|
# of overwriting concurrent changes merely to make the check pass.
|
|
103
|
-
|
|
104
|
+
# Push only the dossier paths, never the whole project folder: a large project
|
|
105
|
+
# re-walks thousands of unchanged files and exceeds the foreground timeout.
|
|
106
|
+
# When the new sync engine owns the vault, `hq sync push` is refused; the
|
|
107
|
+
# engine uploads the files and the read-back below waits for them.
|
|
108
|
+
ENGINE_OWNED=0
|
|
109
|
+
if hq_delegate_engine_owns_vault "$COMPANY"; then ENGINE_OWNED=1; fi
|
|
110
|
+
if [ "$ENGINE_OWNED" -eq 0 ]; then
|
|
111
|
+
hq sync push "$REL/delegation/$ID/" --company "$COMPANY" --on-conflict keep || die 'final dossier push failed; resume publication'
|
|
112
|
+
while IFS= read -r file; do
|
|
113
|
+
[ -n "$file" ] && [ -e "$file" ] || continue
|
|
114
|
+
hq sync push "${file#"$HQ_ROOT/"}" --company "$COMPANY" --on-conflict keep || die 'final dossier push failed; resume publication'
|
|
115
|
+
done <<EOF
|
|
116
|
+
$SNAPSHOT_FILES
|
|
117
|
+
EOF
|
|
118
|
+
fi
|
|
104
119
|
cp "$STAGE/hashes" "$STAGE/receipts"
|
|
105
120
|
jq -cn --arg key "$REL/delegation/$ID/manifest.json" --arg value "$(file_hash "$DEST/manifest.json")" '{key:$key,value:$value}' >> "$STAGE/receipts"
|
|
106
121
|
while IFS= read -r row; do
|
|
107
122
|
path="$(printf '%s' "$row" | jq -r '.key')"
|
|
108
123
|
expected="$(printf '%s' "$row" | jq -r '.value')"
|
|
109
124
|
matched=0
|
|
125
|
+
if [ "$ENGINE_OWNED" -eq 1 ]; then
|
|
126
|
+
hq_delegate_wait_for_cloud "$COMPANY" "${path#"companies/$COMPANY/"}" "$expected" && matched=1
|
|
127
|
+
[ "$matched" -eq 1 ] || die "the sync engine has not uploaded $path (or the vault holds other bytes) after $(hq_delegate_engine_wait_seconds)s ($HQ_DELEGATE_ENGINE_WAIT_CAUSES); check 'hq sync-core status', then resume"
|
|
128
|
+
fi
|
|
110
129
|
for delay in 0 1 2; do
|
|
130
|
+
[ "$matched" -eq 0 ] || break
|
|
111
131
|
[ "$delay" -eq 0 ] || sleep "$delay"
|
|
112
132
|
if hq files cat "${path#"companies/$COMPANY/"}" --company "$COMPANY" > "$STAGE/remote"; then
|
|
113
133
|
if [ "$(file_hash "$STAGE/remote")" = "$expected" ]; then matched=1; break; fi
|
|
@@ -60,7 +60,13 @@ REPO_REL="$(jq -r '.repo.path // empty' "$MANIFEST")"
|
|
|
60
60
|
BRANCH="$(jq -r '.repo.branch // empty' "$MANIFEST")"
|
|
61
61
|
[ -n "$REPO_REL" ] || die "manifest repo block has no path"
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
# repo.path is HQ-root-relative (repos/private/x) or, for a project whose PRD
|
|
64
|
+
# names a repo outside the HQ tree, absolute (feedback_6ea99712). Prefixing the
|
|
65
|
+
# root to an absolute path produced "<root>//Users/...".
|
|
66
|
+
case "$REPO_REL" in
|
|
67
|
+
/*|[A-Za-z]:[\\/]*) REPO_DIR="$REPO_REL" ;;
|
|
68
|
+
*) REPO_DIR="$HQ_ROOT/$REPO_REL" ;;
|
|
69
|
+
esac
|
|
64
70
|
[ -d "$REPO_DIR/.git" ] || git -C "$REPO_DIR" rev-parse --git-dir >/dev/null 2>&1 \
|
|
65
71
|
|| die "not a git repository: $REPO_DIR"
|
|
66
72
|
|
|
@@ -9,13 +9,19 @@
|
|
|
9
9
|
# [--env-schema <path>]
|
|
10
10
|
#
|
|
11
11
|
# Behavior:
|
|
12
|
-
# - derives required secret NAMES from
|
|
13
|
-
#
|
|
14
|
-
#
|
|
12
|
+
# - derives required secret NAMES from, in order: --env-schema, the project
|
|
13
|
+
# folder's .env.schema, prd.json metadata.secrets, then the repo's
|
|
14
|
+
# .env.schema (the widest source, used only when the project declares
|
|
15
|
+
# nothing); no source -> records secrets: [] and says so plainly rather
|
|
16
|
+
# than guessing at credentials. The plan output names the source.
|
|
17
|
+
# - before sharing anything, every name is checked against
|
|
18
|
+
# `hq secrets list --company <co>` (names only); one missing name aborts
|
|
19
|
+
# the whole step with nothing shared
|
|
15
20
|
# - without --yes: prints a full-prose confirmation listing every name and
|
|
16
21
|
# the principal, then exits 2 granting nothing — this step is a privilege
|
|
17
22
|
# handover and gets its own confirmation, separate from the file grants
|
|
18
|
-
# - with --yes: hq secrets share <NAME> --with <principal>
|
|
23
|
+
# - with --yes: hq secrets --company <co> share <NAME> --with <principal>
|
|
24
|
+
# --permission read (agent/person uids use the grant step's grantPrincipal)
|
|
19
25
|
# per name, then records the names (and only the names) in the manifest
|
|
20
26
|
# - --no-secrets: skips everything, records {secrets: [], secretsSkipped: true}
|
|
21
27
|
#
|
|
@@ -57,6 +63,23 @@ PROJECT="$(jq -r '.project.name // empty' "$MANIFEST")"
|
|
|
57
63
|
[ -n "$COMPANY" ] || die "manifest has no company"
|
|
58
64
|
[ -n "$PRINCIPAL" ] || die "manifest has no to.principal"
|
|
59
65
|
|
|
66
|
+
# Secret-ACL principals must be an email, grp_<id>, out_<id>, or @all. An
|
|
67
|
+
# agent (agt_...) or person uid (prs_...) is rejected by `hq secrets share`, so
|
|
68
|
+
# share with the principal the grant step resolved and recorded in
|
|
69
|
+
# .grantPrincipal: the per-agent delegation group (grp_dlg...) for an agent,
|
|
70
|
+
# the mapped email for a person uid. The grant step runs first.
|
|
71
|
+
SHARE_PRINCIPAL="$PRINCIPAL"
|
|
72
|
+
case "$PRINCIPAL" in
|
|
73
|
+
agt_*|prs_*)
|
|
74
|
+
RECORDED="$(jq -r '.grantPrincipal // empty' "$MANIFEST" | tr -d '\r')"
|
|
75
|
+
case "$PRINCIPAL:$RECORDED" in
|
|
76
|
+
agt_*:grp_dlg*) SHARE_PRINCIPAL="$RECORDED" ;;
|
|
77
|
+
prs_*:?*@?*) SHARE_PRINCIPAL="$RECORDED" ;;
|
|
78
|
+
*) SHARE_PRINCIPAL="" ;;
|
|
79
|
+
esac
|
|
80
|
+
;;
|
|
81
|
+
esac
|
|
82
|
+
|
|
60
83
|
update_manifest() { # jq-filter
|
|
61
84
|
local tmp
|
|
62
85
|
tmp="$(mktemp)"
|
|
@@ -73,27 +96,46 @@ fi
|
|
|
73
96
|
|
|
74
97
|
# --- discover the env schema --------------------------------------------------
|
|
75
98
|
|
|
76
|
-
|
|
99
|
+
# Narrowest declaration first. A project-scoped source (the project folder's
|
|
100
|
+
# .env.schema or prd.json metadata.secrets) names what this lane needs; the
|
|
101
|
+
# repo's .env.schema names everything the whole repo needs and is only used
|
|
102
|
+
# when the project declares nothing.
|
|
103
|
+
SOURCE_KIND="" SOURCE_PATH="" NAMES=""
|
|
104
|
+
NAME_RE='^[A-Z][A-Z0-9_]*(/[A-Z][A-Z0-9_]+)*$'
|
|
105
|
+
names_from_schema() { # schema-path -> stdout (KEY= lines; comments and blanks ignored)
|
|
106
|
+
grep -E '^[A-Z][A-Z0-9_]*(/[A-Z][A-Z0-9_]+)*=' "$1" | cut -d= -f1 | sort -u
|
|
107
|
+
}
|
|
108
|
+
PROJECT_DIR="$HQ_ROOT/companies/$COMPANY/projects/$PROJECT"
|
|
109
|
+
if [ -n "$ENV_SCHEMA" ]; then
|
|
110
|
+
[ -f "$ENV_SCHEMA" ] || die "--env-schema not found: $ENV_SCHEMA"
|
|
111
|
+
SOURCE_KIND="--env-schema"; SOURCE_PATH="$ENV_SCHEMA"
|
|
112
|
+
NAMES="$(names_from_schema "$ENV_SCHEMA")"
|
|
113
|
+
elif [ -f "$PROJECT_DIR/.env.schema" ]; then
|
|
114
|
+
SOURCE_KIND="project .env.schema"; SOURCE_PATH="$PROJECT_DIR/.env.schema"
|
|
115
|
+
NAMES="$(names_from_schema "$SOURCE_PATH")"
|
|
116
|
+
elif [ -f "$PROJECT_DIR/prd.json" ] \
|
|
117
|
+
&& jq -e '(.metadata.secrets // null) | type == "array" and length > 0' "$PROJECT_DIR/prd.json" >/dev/null 2>&1; then
|
|
118
|
+
SOURCE_KIND="prd.json metadata.secrets"; SOURCE_PATH="$PROJECT_DIR/prd.json"
|
|
119
|
+
NAMES="$(jq -r '.metadata.secrets[] | if type == "object" then (.name // empty) else . end' "$SOURCE_PATH" | sort -u)"
|
|
120
|
+
BAD="$(printf '%s\n' "$NAMES" | grep -v -E "$NAME_RE" || true)"
|
|
121
|
+
[ -z "$BAD" ] || die "prd.json metadata.secrets has an entry that is not a secret name: $(printf '%s' "$BAD" | tr '\n' ' ')— nothing granted"
|
|
122
|
+
else
|
|
77
123
|
REPO_REL="$(jq -r '.repo.path // empty' "$MANIFEST")"
|
|
78
|
-
|
|
79
|
-
"$HQ_ROOT
|
|
80
|
-
"$
|
|
81
|
-
|
|
82
|
-
done
|
|
124
|
+
if [ -n "$REPO_REL" ] && [ -f "$HQ_ROOT/$REPO_REL/.env.schema" ]; then
|
|
125
|
+
SOURCE_KIND="repo .env.schema"; SOURCE_PATH="$HQ_ROOT/$REPO_REL/.env.schema"
|
|
126
|
+
NAMES="$(names_from_schema "$SOURCE_PATH")"
|
|
127
|
+
fi
|
|
83
128
|
fi
|
|
84
129
|
|
|
85
|
-
if [ -z "$
|
|
130
|
+
if [ -z "$SOURCE_PATH" ]; then
|
|
86
131
|
update_manifest '.secrets = [] | .secretsSkipped = false'
|
|
87
|
-
echo "hq-delegate-secrets: no .env.schema found for this project or its repo — no secret names to grant. If the project needs credentials, add
|
|
132
|
+
echo "hq-delegate-secrets: no .env.schema found for this project or its repo, and prd.json declares no metadata.secrets — no secret names to grant. If the project needs credentials, add a project .env.schema (or prd.json metadata.secrets) and re-run, or grant them manually with 'hq secrets share'."
|
|
88
133
|
exit 0
|
|
89
134
|
fi
|
|
90
135
|
|
|
91
|
-
# --- parse names (KEY= lines; comments and blanks ignored) --------------------
|
|
92
|
-
|
|
93
|
-
NAMES="$(grep -E '^[A-Z][A-Z0-9_]*(/[A-Z][A-Z0-9_]+)*=' "$ENV_SCHEMA" | cut -d= -f1 | sort -u)"
|
|
94
136
|
if [ -z "$NAMES" ]; then
|
|
95
137
|
update_manifest '.secrets = [] | .secretsSkipped = false'
|
|
96
|
-
echo "hq-delegate-secrets: $
|
|
138
|
+
echo "hq-delegate-secrets: $SOURCE_PATH declares no secret names — nothing to grant"
|
|
97
139
|
exit 0
|
|
98
140
|
fi
|
|
99
141
|
NAME_COUNT="$(printf '%s\n' "$NAMES" | wc -l | tr -d ' ')"
|
|
@@ -102,10 +144,23 @@ NAME_COUNT="$(printf '%s\n' "$NAMES" | wc -l | tr -d ' ')"
|
|
|
102
144
|
|
|
103
145
|
echo "Secret access handover — this grants the recipient the ability to use these credentials."
|
|
104
146
|
echo
|
|
105
|
-
echo "
|
|
147
|
+
echo "Source: $SOURCE_KIND ($SOURCE_PATH)"
|
|
148
|
+
if [ "$SOURCE_KIND" = "repo .env.schema" ]; then
|
|
149
|
+
echo "The project declares no secrets of its own, so the repo-wide schema is used. Narrow it with a project .env.schema or prd.json metadata.secrets if the lane needs fewer."
|
|
150
|
+
fi
|
|
151
|
+
echo
|
|
152
|
+
echo "The following $NAME_COUNT secret name(s), declared by $(basename "$SOURCE_PATH") for project '$PROJECT', will be shared with read permission to '$PRINCIPAL' in company '$COMPANY':"
|
|
106
153
|
echo
|
|
107
154
|
printf '%s\n' "$NAMES" | sed 's/^/ - /'
|
|
108
155
|
echo
|
|
156
|
+
if [ "$SHARE_PRINCIPAL" != "$PRINCIPAL" ]; then
|
|
157
|
+
if [ -n "$SHARE_PRINCIPAL" ]; then
|
|
158
|
+
echo "Access flows through '$SHARE_PRINCIPAL', the principal the grant step resolved for '$PRINCIPAL'."
|
|
159
|
+
else
|
|
160
|
+
echo "Access will flow through the principal the grant step records for '$PRINCIPAL' (run hq-delegate-grant.sh --yes first)."
|
|
161
|
+
fi
|
|
162
|
+
echo
|
|
163
|
+
fi
|
|
109
164
|
echo "Only the names are granted and recorded; no secret value is read, printed, or transmitted by this step. The recipient consumes them through 'hq run' / 'hq secrets exec'."
|
|
110
165
|
|
|
111
166
|
if [ "$YES" -ne 1 ]; then
|
|
@@ -116,10 +171,30 @@ fi
|
|
|
116
171
|
|
|
117
172
|
# --- grant each name (names only — never a value read) ------------------------
|
|
118
173
|
|
|
174
|
+
[ -n "$SHARE_PRINCIPAL" ] \
|
|
175
|
+
|| die "recipient '$PRINCIPAL' cannot be a secret-ACL principal and the manifest has no usable grantPrincipal — run hq-delegate-grant.sh --yes first; nothing granted"
|
|
176
|
+
|
|
177
|
+
# Every name must exist in the company vault before any share runs, so a
|
|
178
|
+
# typo or an undeclared secret never leaves a partial grant behind. Names
|
|
179
|
+
# only: `hq secrets list` prints no values.
|
|
180
|
+
LISTED="$(hq secrets list --company "$COMPANY" 2>/dev/null)" \
|
|
181
|
+
|| die "could not list secret names for company '$COMPANY' (hq secrets list failed) — nothing granted"
|
|
182
|
+
MISSING=""
|
|
183
|
+
while IFS= read -r name; do
|
|
184
|
+
[ -n "$name" ] || continue
|
|
185
|
+
printf '%s\n' "$LISTED" | awk -v n="$name" '$1 == n { found = 1 } END { exit !found }' \
|
|
186
|
+
|| MISSING="$MISSING $name"
|
|
187
|
+
done <<EOF
|
|
188
|
+
$NAMES
|
|
189
|
+
EOF
|
|
190
|
+
if [ -n "$MISSING" ]; then
|
|
191
|
+
die "these name(s) from $SOURCE_KIND do not exist in company '$COMPANY':${MISSING} — nothing granted; add them with 'hq secrets set' or remove them from $SOURCE_PATH, then re-run"
|
|
192
|
+
fi
|
|
193
|
+
|
|
119
194
|
printf '%s\n' "$NAMES" | while IFS= read -r name; do
|
|
120
|
-
hq secrets share "$name" --with "$
|
|
121
|
-
|| die "failed to grant '$name' to '$
|
|
122
|
-
echo "hq-delegate-secrets: granted read on '$name' to '$
|
|
195
|
+
hq secrets --company "$COMPANY" share "$name" --with "$SHARE_PRINCIPAL" --permission read \
|
|
196
|
+
|| die "failed to grant '$name' to '$SHARE_PRINCIPAL' — aborting; manifest not updated"
|
|
197
|
+
echo "hq-delegate-secrets: granted read on '$name' to '$SHARE_PRINCIPAL'"
|
|
123
198
|
done
|
|
124
199
|
|
|
125
200
|
NAMES_JSON="$(printf '%s\n' "$NAMES" | jq -R . | jq -cs .)"
|