@indigoai-us/hq-cli 5.345.223 → 5.345.225

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.
Files changed (96) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/assets/bot-workers/setup/context/quick-reference.md +2 -2
  3. package/assets/mesh-daemon/README.md +11 -12
  4. package/dist/command-catalog.generated.d.ts +78 -4
  5. package/dist/command-catalog.generated.js +94 -4
  6. package/dist/commands/cloud-provision.d.ts +4 -1
  7. package/dist/commands/cloud-provision.js +7 -3
  8. package/dist/commands/cloud-retire.js +1 -1
  9. package/dist/commands/core-delegate-w1b.js +3 -1
  10. package/dist/commands/core-delegate.d.ts +5 -0
  11. package/dist/commands/core-dm-bind-native.d.ts +5 -1
  12. package/dist/commands/core-dm-bind-native.js +4 -0
  13. package/dist/commands/core-job-notify-native.d.ts +5 -1
  14. package/dist/commands/core-job-notify-native.js +8 -2
  15. package/dist/commands/core-jobs-native.d.ts +27 -1
  16. package/dist/commands/core-jobs-native.js +49 -28
  17. package/dist/commands/core-pipeline-conductor-native.js +7 -7
  18. package/dist/commands/core-pipeline-driver-native.js +5 -5
  19. package/dist/commands/core-refresh-vault-access-native.d.ts +5 -0
  20. package/dist/commands/core-refresh-vault-access-native.js +3 -1
  21. package/dist/commands/core-work-mesh-bind-trusted-native.js +1 -1
  22. package/dist/commands/daemon.d.ts +2 -0
  23. package/dist/commands/daemon.js +67 -1
  24. package/dist/commands/lanes-hold.d.ts +2 -27
  25. package/dist/commands/lanes-hold.js +3 -75
  26. package/dist/commands/lanes-loop.js +1 -1
  27. package/dist/commands/lanes-session-start.js +2 -2
  28. package/dist/commands/mesh.d.ts +12 -0
  29. package/dist/commands/mesh.js +13 -4
  30. package/dist/commands/monitor.js +1 -1
  31. package/dist/commands/packs.js +1 -1
  32. package/dist/commands/whoami.d.ts +10 -17
  33. package/dist/commands/whoami.js +7 -79
  34. package/dist/data/command-states.json +13 -0
  35. package/dist/index.js +1 -1
  36. package/dist/lib/daemon/catalog.d.ts +8 -5
  37. package/dist/lib/daemon/catalog.js +13 -7
  38. package/dist/lib/daemon/config.d.ts +5 -0
  39. package/dist/lib/daemon/config.js +6 -0
  40. package/dist/lib/daemon/lanes-monitor-state.d.ts +55 -0
  41. package/dist/lib/daemon/lanes-monitor-state.js +129 -0
  42. package/dist/lib/daemon/lanes-reconcile-loader.d.ts +7 -0
  43. package/dist/lib/daemon/lanes-reconcile-loader.js +13 -0
  44. package/dist/lib/daemon/merge-sections.d.ts +165 -0
  45. package/dist/lib/daemon/merge-sections.js +556 -0
  46. package/dist/lib/daemon/ops/policy.d.ts +1 -1
  47. package/dist/lib/daemon/ops/policy.js +1 -1
  48. package/dist/lib/daemon/protocol.d.ts +1 -1
  49. package/dist/lib/daemon/protocol.js +0 -6
  50. package/dist/lib/daemon/run.js +73 -1
  51. package/dist/lib/daemon/selfcheck.js +2 -2
  52. package/dist/lib/daemon/server.d.ts +2 -4
  53. package/dist/lib/daemon/server.js +5 -48
  54. package/dist/lib/daemon/state-file.d.ts +74 -4
  55. package/dist/lib/daemon/state-file.js +159 -19
  56. package/dist/lib/daemon/supervisor.d.ts +1 -1
  57. package/dist/lib/daemon/updater.d.ts +2 -6
  58. package/dist/lib/daemon/updater.js +4 -11
  59. package/dist/lib/daemon/whoami-cache.d.ts +96 -0
  60. package/dist/lib/daemon/whoami-cache.js +244 -0
  61. package/dist/lib/hook-engine/coverage.d.ts +2 -0
  62. package/dist/lib/hook-engine/coverage.js +71 -0
  63. package/dist/lib/hook-engine/native-precompact-compatibility.json +449 -0
  64. package/dist/lib/hook-engine/reconcile.js +14 -8
  65. package/dist/lib/install/hook-target.d.ts +13 -3
  66. package/dist/lib/install/hook-target.js +14 -11
  67. package/dist/lib/lanes/envelope-repair-dispatch.js +1 -1
  68. package/dist/lib/lanes/monitor.d.ts +2 -0
  69. package/dist/lib/lanes/monitor.js +2 -1
  70. package/dist/lib/lanes/registry-flag.d.ts +6 -0
  71. package/dist/lib/lanes/registry-flag.js +3 -2
  72. package/dist/lib/lanes/repo-merge-hold.d.ts +39 -0
  73. package/dist/lib/lanes/repo-merge-hold.js +90 -0
  74. package/dist/lib/lanes/watcher-main.js +3 -3
  75. package/dist/lib/mesh/live/daemon/doctor.js +1 -1
  76. package/dist/lib/mesh/live/daemon/install.js +2 -2
  77. package/dist/lib/windows/install-followup.js +1 -1
  78. package/dist/utils/client-health-contract.d.ts +1 -0
  79. package/dist/utils/client-health-contract.js +5 -0
  80. package/dist/utils/client-health.d.ts +2 -0
  81. package/dist/utils/client-health.js +40 -0
  82. package/dist/utils/cognito-session.d.ts +2 -14
  83. package/dist/utils/cognito-session.js +2 -40
  84. package/dist/utils/daemon-cli-version.d.ts +13 -0
  85. package/dist/utils/daemon-cli-version.js +47 -0
  86. package/dist/utils/duplicate-command-usage.js +1 -1
  87. package/dist/utils/machine-token-cache.d.ts +21 -0
  88. package/dist/utils/machine-token-cache.js +49 -0
  89. package/dist/utils/resident-package-preload.js +4 -0
  90. package/dist/utils/whoami-identity.d.ts +54 -0
  91. package/dist/utils/whoami-identity.js +108 -0
  92. package/package.json +7 -7
  93. package/dist/lib/daemon/ops/memory.d.ts +0 -18
  94. package/dist/lib/daemon/ops/memory.js +0 -65
  95. package/dist/lib/daemon/ops/mesh.d.ts +0 -38
  96. package/dist/lib/daemon/ops/mesh.js +0 -70
@@ -0,0 +1,165 @@
1
+ /**
2
+ * The two merge sections of the daemon's state file (state-file.ts):
3
+ *
4
+ * - merge_holds: every repository merge hold record under
5
+ * <hqRoot>/workspace/lanes/holds, grouped by the company that owns it, with
6
+ * that company's `lanes.repo-merge-hold` flag;
7
+ * - merge_approvals: per session id, the conduct-link decision queue that
8
+ * gates the session's merges, the session's company, and whether the
9
+ * `lanes.review-before-merge` gate applies to it, with the lane review
10
+ * records.
11
+ *
12
+ * The native merge check in crates/hq-hook reads only these two sections and
13
+ * starts no process. It refuses every merge while a section is missing, has a
14
+ * missing or wrongly typed field, or its `refreshed_at` is older than
15
+ * min(max_age_seconds, 60) seconds, so whenever a decision cannot be made here
16
+ * the section (or the session) is written so the check refuses:
17
+ *
18
+ * - a hold file `hq lanes hold` would refuse, an unreadable holds folder, or
19
+ * an unreadable `lanes.repo-merge-hold` flag omits merge_holds;
20
+ * - an unreadable link folder omits merge_approvals;
21
+ * - a session the conduct gate covers (a link pointer and a decision queue)
22
+ * whose company cannot be resolved is written with queue_status
23
+ * "unreadable";
24
+ * - an unreadable `lanes.review-before-merge` flag writes review_required
25
+ * true with no reviews.
26
+ *
27
+ * Files are read through src/lib/safe-store.ts (a regular single-link file of
28
+ * this user in a folder no other user can write), except lane records and
29
+ * review records, which are read with their stores' own validating readers.
30
+ * Nothing here starts a process; the flags are read from the flag registry.
31
+ */
32
+ import { type RepoMergeHold } from "../lanes/repo-merge-hold.js";
33
+ import { type LaneCompanyRef } from "../lanes/types.js";
34
+ export declare const MERGE_HOLDS_SCHEMA = "merge-holds.v1";
35
+ export declare const MERGE_APPROVALS_SCHEMA = "merge-approvals.v1";
36
+ /** Written as each section's max_age_seconds; the native check caps it at 60 anyway. */
37
+ export declare const MERGE_SECTION_MAX_AGE_SECONDS = 60;
38
+ /**
39
+ * How long after one refresh finishes the next starts. A section is refused
40
+ * past 60 s, so this plus two refresh durations (each bounded by
41
+ * MERGE_FLAG_READ_TIMEOUT_MS) stays under it.
42
+ */
43
+ export declare const MERGE_SECTION_REFRESH_INTERVAL_MS = 15000;
44
+ /** A flag value is asked of the registry again after this long. */
45
+ export declare const MERGE_FLAG_TTL_MS = 30000;
46
+ /** A flag read that takes longer than this counts as unreadable. */
47
+ export declare const MERGE_FLAG_READ_TIMEOUT_MS = 12000;
48
+ export interface MergeHoldEntry {
49
+ repo: string;
50
+ reason: string;
51
+ set_at: string;
52
+ until: string;
53
+ released_at: string | null;
54
+ }
55
+ export interface MergeHoldsCompany {
56
+ slug: string;
57
+ enabled: boolean;
58
+ holds: MergeHoldEntry[];
59
+ }
60
+ export interface MergeHoldsSection {
61
+ schema: typeof MERGE_HOLDS_SCHEMA;
62
+ refreshed_at: string;
63
+ max_age_seconds: number;
64
+ companies: Record<string, MergeHoldsCompany>;
65
+ }
66
+ export interface MergeDecision {
67
+ status: string;
68
+ ref: string;
69
+ answer: string;
70
+ }
71
+ export interface MergeReview {
72
+ repo: string;
73
+ pr: number;
74
+ head_sha: string;
75
+ }
76
+ export type MergeQueueStatus = "present" | "absent" | "unreadable";
77
+ export interface MergeApprovalSession {
78
+ company_uid: string;
79
+ company_slug: string;
80
+ link_id: string;
81
+ queue_status: MergeQueueStatus;
82
+ decisions: MergeDecision[];
83
+ review_required: boolean;
84
+ reviews: MergeReview[];
85
+ }
86
+ export interface MergeApprovalsSection {
87
+ schema: typeof MERGE_APPROVALS_SCHEMA;
88
+ refreshed_at: string;
89
+ max_age_seconds: number;
90
+ sessions: Record<string, MergeApprovalSession>;
91
+ }
92
+ export interface MergeSections {
93
+ merge_holds: MergeHoldsSection | null;
94
+ merge_approvals: MergeApprovalsSection | null;
95
+ }
96
+ /** A lanes flag for one company: its value, or null when it could not be read. */
97
+ export type MergeFlagReader = (flag: string, company: LaneCompanyRef) => Promise<boolean | null>;
98
+ export interface MergeSectionInput {
99
+ hqRoot: string;
100
+ /** Written as refreshed_at; take it before any file is read. */
101
+ now: Date;
102
+ readFlag: MergeFlagReader;
103
+ }
104
+ /**
105
+ * Every hold record, or null when any of them is one `hq lanes hold list`
106
+ * would refuse (unreadable, not JSON, invalid fields, or a file name that
107
+ * does not match its repository), or when the folder cannot be read.
108
+ */
109
+ export declare function readMergeHoldRecords(hqRoot: string): RepoMergeHold[] | null;
110
+ /** The merge_holds section, or null to leave it out of the state file. */
111
+ export declare function buildMergeHoldsSection(input: MergeSectionInput): Promise<MergeHoldsSection | null>;
112
+ export interface FoldedQueue {
113
+ decisions: MergeDecision[];
114
+ /** Rows with an id whose latest state lacks a string status, ref or answer. */
115
+ skipped: number;
116
+ }
117
+ /**
118
+ * A conduct decision queue folded to the latest state of each row id, in
119
+ * first-seen order: later rows override earlier fields. Blank and unparseable
120
+ * lines (a torn last line among them) and rows without an id are skipped.
121
+ */
122
+ export declare function foldDecisionQueue(text: string): FoldedQueue;
123
+ /** The merge_approvals section, or null to leave it out of the state file. */
124
+ export declare function buildMergeApprovalsSection(input: MergeSectionInput): Promise<MergeApprovalsSection | null>;
125
+ /** Both sections, read at `input.now`. A builder that throws leaves its section out. */
126
+ export declare function buildMergeSections(input: MergeSectionInput): Promise<MergeSections>;
127
+ export interface RegistryMergeFlagReaderOptions {
128
+ env: NodeJS.ProcessEnv;
129
+ ttlMs?: number;
130
+ timeoutMs?: number;
131
+ now?: () => number;
132
+ /** Test seam: one registry read; null when it could not be read. */
133
+ read?: (flag: string, company: LaneCompanyRef, env: NodeJS.ProcessEnv) => Promise<boolean | null>;
134
+ }
135
+ /**
136
+ * Lanes flags as `hq lanes hold check` reads them (readLanesRegistryFlag: local
137
+ * override, then the registry, then its last-known-good cache on a transient
138
+ * failure), asked again after `ttlMs`. A read that fails, throws or takes
139
+ * longer than `timeoutMs` is null and is not kept.
140
+ */
141
+ export declare function createRegistryMergeFlagReader(options: RegistryMergeFlagReaderOptions): MergeFlagReader;
142
+ export interface MergeSectionRefresher {
143
+ /** The latest sections, each only while younger than its max age. */
144
+ latest(): MergeSections;
145
+ /** Build once now (tests); resolves when the result is kept. */
146
+ refresh(): Promise<void>;
147
+ close(): void;
148
+ }
149
+ export interface MergeSectionRefresherOptions {
150
+ /** The HQ root, or undefined when none is configured (both sections are left out). */
151
+ hqRoot: () => string | undefined;
152
+ readFlag: MergeFlagReader;
153
+ /** Called after each refresh, to rewrite the state file. */
154
+ onRefresh?: () => void;
155
+ intervalMs?: number;
156
+ wallClock?: () => Date;
157
+ /** Start the timer (default true). */
158
+ start?: boolean;
159
+ }
160
+ /**
161
+ * Rebuild both sections now and then every `intervalMs` after the previous
162
+ * build finished, and hand each result to `onRefresh`. Builds never overlap.
163
+ */
164
+ export declare function startMergeSectionRefresh(options: MergeSectionRefresherOptions): MergeSectionRefresher;
165
+ //# sourceMappingURL=merge-sections.d.ts.map