@telora/daemon 0.20.57 → 0.20.78

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 (114) hide show
  1. package/build-info.json +4 -3
  2. package/dist/audit-phase.d.ts +12 -18
  3. package/dist/audit-phase.d.ts.map +1 -1
  4. package/dist/audit-phase.js +17 -60
  5. package/dist/audit-phase.js.map +1 -1
  6. package/dist/audit-prompt.d.ts +44 -0
  7. package/dist/audit-prompt.d.ts.map +1 -0
  8. package/dist/audit-prompt.js +194 -0
  9. package/dist/audit-prompt.js.map +1 -0
  10. package/dist/ci-sensor-loop.d.ts +38 -1
  11. package/dist/ci-sensor-loop.d.ts.map +1 -1
  12. package/dist/ci-sensor-loop.js +49 -5
  13. package/dist/ci-sensor-loop.js.map +1 -1
  14. package/dist/delivery-reconciler.d.ts +3 -0
  15. package/dist/delivery-reconciler.d.ts.map +1 -1
  16. package/dist/delivery-reconciler.js +16 -0
  17. package/dist/delivery-reconciler.js.map +1 -1
  18. package/dist/focus-engine.d.ts.map +1 -1
  19. package/dist/focus-engine.js +12 -1
  20. package/dist/focus-engine.js.map +1 -1
  21. package/dist/focus-executor.d.ts.map +1 -1
  22. package/dist/focus-executor.js +4 -1
  23. package/dist/focus-executor.js.map +1 -1
  24. package/dist/focus-merge.d.ts.map +1 -1
  25. package/dist/focus-merge.js +37 -3
  26. package/dist/focus-merge.js.map +1 -1
  27. package/dist/focus-stage-lifecycle/wedge-watchdog.d.ts.map +1 -1
  28. package/dist/focus-stage-lifecycle/wedge-watchdog.js +9 -1
  29. package/dist/focus-stage-lifecycle/wedge-watchdog.js.map +1 -1
  30. package/dist/listener-auto-advance.d.ts.map +1 -1
  31. package/dist/listener-auto-advance.js +58 -10
  32. package/dist/listener-auto-advance.js.map +1 -1
  33. package/dist/merge-back-loop.d.ts +8 -2
  34. package/dist/merge-back-loop.d.ts.map +1 -1
  35. package/dist/merge-back-loop.js +17 -11
  36. package/dist/merge-back-loop.js.map +1 -1
  37. package/dist/merge-failure-classify.d.ts +39 -0
  38. package/dist/merge-failure-classify.d.ts.map +1 -0
  39. package/dist/merge-failure-classify.js +58 -0
  40. package/dist/merge-failure-classify.js.map +1 -0
  41. package/dist/prompt-sections/execution-sections.d.ts +20 -14
  42. package/dist/prompt-sections/execution-sections.d.ts.map +1 -1
  43. package/dist/prompt-sections/execution-sections.js +53 -138
  44. package/dist/prompt-sections/execution-sections.js.map +1 -1
  45. package/dist/prompt-sections/scoping-sections.d.ts +30 -0
  46. package/dist/prompt-sections/scoping-sections.d.ts.map +1 -0
  47. package/dist/prompt-sections/scoping-sections.js +179 -0
  48. package/dist/prompt-sections/scoping-sections.js.map +1 -0
  49. package/dist/prompt-sections/shared.d.ts +7 -0
  50. package/dist/prompt-sections/shared.d.ts.map +1 -1
  51. package/dist/prompt-sections/shared.js.map +1 -1
  52. package/dist/queries/agent-resolvable-promotion.d.ts +87 -0
  53. package/dist/queries/agent-resolvable-promotion.d.ts.map +1 -0
  54. package/dist/queries/agent-resolvable-promotion.js +152 -0
  55. package/dist/queries/agent-resolvable-promotion.js.map +1 -0
  56. package/dist/queries/cause-key.d.ts +64 -0
  57. package/dist/queries/cause-key.d.ts.map +1 -0
  58. package/dist/queries/cause-key.js +79 -0
  59. package/dist/queries/cause-key.js.map +1 -0
  60. package/dist/queries/escalation-suppression.d.ts +89 -0
  61. package/dist/queries/escalation-suppression.d.ts.map +1 -0
  62. package/dist/queries/escalation-suppression.js +98 -0
  63. package/dist/queries/escalation-suppression.js.map +1 -0
  64. package/dist/queries/holds.d.ts +177 -0
  65. package/dist/queries/holds.d.ts.map +1 -0
  66. package/dist/queries/holds.js +232 -0
  67. package/dist/queries/holds.js.map +1 -0
  68. package/dist/queries/issues.d.ts +41 -99
  69. package/dist/queries/issues.d.ts.map +1 -1
  70. package/dist/queries/issues.js +57 -137
  71. package/dist/queries/issues.js.map +1 -1
  72. package/dist/queries/verification.d.ts +11 -0
  73. package/dist/queries/verification.d.ts.map +1 -1
  74. package/dist/queries/verification.js.map +1 -1
  75. package/dist/resolvers/shared/git-diff.d.ts +24 -3
  76. package/dist/resolvers/shared/git-diff.d.ts.map +1 -1
  77. package/dist/resolvers/shared/git-diff.js +41 -3
  78. package/dist/resolvers/shared/git-diff.js.map +1 -1
  79. package/dist/spawn/prompt-assembly.d.ts +3 -0
  80. package/dist/spawn/prompt-assembly.d.ts.map +1 -1
  81. package/dist/spawn/prompt-assembly.js +2 -1
  82. package/dist/spawn/prompt-assembly.js.map +1 -1
  83. package/dist/spawn/worktree-session.d.ts +2 -0
  84. package/dist/spawn/worktree-session.d.ts.map +1 -1
  85. package/dist/spawn/worktree-session.js +20 -1
  86. package/dist/spawn/worktree-session.js.map +1 -1
  87. package/dist/staleness-sensor.d.ts +24 -1
  88. package/dist/staleness-sensor.d.ts.map +1 -1
  89. package/dist/staleness-sensor.js +31 -4
  90. package/dist/staleness-sensor.js.map +1 -1
  91. package/dist/stall-detectors.d.ts +46 -13
  92. package/dist/stall-detectors.d.ts.map +1 -1
  93. package/dist/stall-detectors.js +78 -18
  94. package/dist/stall-detectors.js.map +1 -1
  95. package/dist/team-prompt-base.d.ts +1 -1
  96. package/dist/team-prompt-base.d.ts.map +1 -1
  97. package/dist/team-prompt-base.js +4 -2
  98. package/dist/team-prompt-base.js.map +1 -1
  99. package/dist/verification-default-on.d.ts.map +1 -1
  100. package/dist/verification-default-on.js +5 -0
  101. package/dist/verification-default-on.js.map +1 -1
  102. package/dist/verification-engine.d.ts +8 -0
  103. package/dist/verification-engine.d.ts.map +1 -1
  104. package/dist/verification-engine.js +8 -75
  105. package/dist/verification-engine.js.map +1 -1
  106. package/dist/verification-evidence.d.ts +74 -0
  107. package/dist/verification-evidence.d.ts.map +1 -0
  108. package/dist/verification-evidence.js +116 -0
  109. package/dist/verification-evidence.js.map +1 -0
  110. package/dist/verification-feedback.d.ts +8 -7
  111. package/dist/verification-feedback.d.ts.map +1 -1
  112. package/dist/verification-feedback.js +49 -39
  113. package/dist/verification-feedback.js.map +1 -1
  114. package/package.json +3 -3
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Delivery hold-lookup queries.
3
+ *
4
+ * "Is something holding this delivery out of done, and what?" -- the escalation
5
+ * side of that question. Two disposition-keyed families live here:
6
+ *
7
+ * - OPERATOR holds (needs_operator / external_wait): a human or an external
8
+ * party must act before the declared work counts as real. Fails CLOSED at
9
+ * its call site.
10
+ * - DIRECTED holds (needs_intent / needs_clarification): an unanswered
11
+ * question the daemon reads back to the asking agent. Fails OPEN at its
12
+ * call site.
13
+ *
14
+ * Plus SELF_REPORT_STALL_HOLD_KINDS: the kinds that are machine-filed alarms
15
+ * ABOUT a delivery's own cycling, excluded from the operator predicate so an
16
+ * alarm cannot constitute the condition it reports.
17
+ *
18
+ * Extracted from queries/issues.ts to keep that file under the daemon
19
+ * file-size limit -- the self-referential-alarm fix pushed it to 844. Bodies
20
+ * verbatim; issues.ts re-exports this surface so existing importers are
21
+ * unaffected.
22
+ *
23
+ * @module queries/holds
24
+ */
25
+ /** Escalation statuses that count as OPEN for every hold lookup here. */
26
+ export declare const OPEN_ESCALATION_STATUSES: ReadonlySet<string>;
27
+ /**
28
+ * The escalation dispositions that mean "a human operator or an external party
29
+ * must act before this delivery's declared work can be considered real":
30
+ * needs_operator (operator/infra/security action) and external_wait (blocked on
31
+ * a third party). Distinct from needs_intent / needs_clarification (a steering
32
+ * question, not a blocked-on-reality signal) and agent_resolvable (no human at
33
+ * all). Keyed on the DISPOSITION axis so ANY escalation kind carrying one of
34
+ * these holds its delivery -- the gate must not enumerate kinds.
35
+ *
36
+ * Declared as daemon-local string literals (not imported from @telora/daemon-core's
37
+ * ESCALATION_DISPOSITIONS) on purpose, mirroring MERGE_CONFLICT_ESCALATION_KIND
38
+ * below: a bare `@telora/*` VALUE import in a query module pulled into a mocked
39
+ * node:test fails to resolve under the module-mock loader (the daemon-local-copy
40
+ * rule). The canonical enum lives in packages/daemon-core/src/disposition.ts and
41
+ * the DB CHECK on agent_escalations.disposition is the real constraint; these
42
+ * strings must stay in sync with it.
43
+ */
44
+ export declare const OPERATOR_HOLD_DISPOSITIONS: readonly string[];
45
+ /**
46
+ * escalation_kind discriminators that are SELF-REFERENTIAL stall alarms: a
47
+ * machine-filed escalation ABOUT a delivery's own cycling, which must NOT be
48
+ * allowed to satisfy the operator-hold predicate that holds that same delivery.
49
+ *
50
+ * The fixpoint this removes (observed 2026-07-26, delivery 50131436, escalations
51
+ * 96262dfa -> 43c4dade): the verify_failed cap detector files
52
+ * verify_gate_unclearable (disposition needs_operator, anchored to the delivery)
53
+ * when iteration_count exceeds the cap. findOpenOperatorHoldForDelivery matched
54
+ * on disposition ONLY, so that alarm satisfied the very hold predicate it was
55
+ * raised about; the delivery was held out of `done`; `done` is the only
56
+ * non-cancelled terminal that makes exceedsVerifyFailedCap stop firing; and
57
+ * iteration_count is monotonic -- so the alarm blocked the only exit that would
58
+ * silence it, and resolving one let the detector file the next on the following
59
+ * tick.
60
+ *
61
+ * ENUMERATION -- every machine-filed, delivery-anchored needs_operator kind, and
62
+ * whether it is a genuine hold or a self-referential stall alarm. The exclusion
63
+ * criterion is narrow and precise: exclude a kind IFF (a) it re-arms while the
64
+ * delivery is non-terminal AND (b) its ONLY silencing is the delivery reaching
65
+ * the terminal state the hold blocks. A kind that describes external reality an
66
+ * operator must change, or that is filed once and silenced by operator
67
+ * resolution, is a GENUINE hold and stays.
68
+ *
69
+ * verify_gate_unclearable (stall-detectors.ts) -- SELF-REFERENTIAL. Trigger
70
+ * (iteration_count) is monotonic and re-arms every tick while non-terminal;
71
+ * silenced only by done/cancelled, which the hold blocks. EXCLUDE.
72
+ * verify_evidence_unavailable (verification-feedback.ts) -- self-REPORT of an
73
+ * instrument fault, but filed ONCE per delivery (idempotent, never re-armed)
74
+ * and silenced by operator resolution, not by `done`. It also already holds
75
+ * the delivery via its OWN gate_state.blocking guard, so it does not lean on
76
+ * this predicate. Not a fixpoint -> KEEP as a hold.
77
+ * schema_drift_blocked (listener-auto-advance.ts) -- operator must apply a
78
+ * migration (external reality). KEEP.
79
+ * advance_blocked (delivery-advance-block.ts) -- dirty worktree / lockfile
80
+ * state an operator or agent must resolve. KEEP.
81
+ * cd_push_failed (ci-escalation.ts) / ci_run_red (ci-sensor-loop.ts) --
82
+ * external CI/CD state. KEEP.
83
+ * propagation_stale (staleness-sensor.ts) -- external propagation state. KEEP.
84
+ *
85
+ * (Focus-anchored kinds -- merge_conflict, merge_refused_dirty,
86
+ * review_window_stalled, stuck_focus_branch -- are never matched by
87
+ * findOpenOperatorHoldForDelivery, which keys on deliveryId, so they need no
88
+ * exclusion here.)
89
+ *
90
+ * Daemon-local literal for the same reason as OPERATOR_HOLD_DISPOSITIONS above:
91
+ * a bare `@telora/*` value import mis-resolves under the node:test module-mock
92
+ * loader, and importing stall-detectors.VERIFY_GATE_UNCLEARABLE_KIND would also
93
+ * form an import cycle (stall-detectors imports from this module). Keep in sync
94
+ * with stall-detectors.VERIFY_GATE_UNCLEARABLE_KIND and the DB CHECK.
95
+ */
96
+ export declare const SELF_REPORT_STALL_HOLD_KINDS: readonly string[];
97
+ /** The open operator-hold escalation a delivery is blocked on (for gate_state). */
98
+ export interface OperatorHoldEscalation {
99
+ id: string;
100
+ escalationKind: string | null;
101
+ disposition: string;
102
+ }
103
+ /**
104
+ * Returns the OPEN (pending|in_review) operator-hold escalation anchored to the
105
+ * given delivery, or null when none is open.
106
+ *
107
+ * DISPOSITION-keyed sibling of hasOpenEscalationForDelivery (which is KIND-keyed):
108
+ * it matches ANY escalation_kind whose disposition is in OPERATOR_HOLD_DISPOSITIONS
109
+ * (needs_operator / external_wait). This is the vocabulary the verify->done gate
110
+ * previously lacked -- an operator blocked ON a delivery (e.g. "the host restore
111
+ * was NOT executed") could not hold that delivery out of done, so a clean review
112
+ * auto-approved it. Returning the matching row (id + kind + disposition), not a
113
+ * bare boolean, lets the gate write the block into the delivery's gate_state.
114
+ *
115
+ * Matches on the typed delivery_id + disposition COLUMNS in preference to the
116
+ * metadata bag, with a metadata fallback (metadata.deliveryId / metadata.disposition)
117
+ * for rows already open at deploy time. The status is re-checked client-side as
118
+ * defense-in-depth against a deploy-lagged edge fn returning resolved rows.
119
+ *
120
+ * escalation_list has NO server-side delivery_id filter, so the delivery match is
121
+ * applied client-side over the org's open rows. Pass `focusId` to narrow the page
122
+ * server-side (the same busy-org paging concern hasOpenWorktreeDirtyEscalation
123
+ * addresses); omit it and the lookup reads the newest 500 open org rows.
124
+ *
125
+ * FAIL-CLOSED is the CALLER's responsibility. This function reports what it finds
126
+ * and THROWS on a hard API error. The verify->done gate that consumes it exists
127
+ * precisely to fail closed, so it must treat a lookup error as "held" -- the
128
+ * opposite of the other escalation lookups (dedup/auto-close), which fail OPEN
129
+ * because a spurious park is worse than a missed dedup. Here a missed hold lets an
130
+ * operator-blocked delivery reach done, which is the failure this gate prevents.
131
+ */
132
+ export declare function findOpenOperatorHoldForDelivery(deliveryId: string, focusId?: string): Promise<OperatorHoldEscalation | null>;
133
+ /**
134
+ * Boolean convenience over findOpenOperatorHoldForDelivery for call sites that
135
+ * only need to know whether the hold exists (not which escalation it is).
136
+ */
137
+ export declare function hasOpenOperatorHoldForDelivery(deliveryId: string, focusId?: string): Promise<boolean>;
138
+ /**
139
+ * The escalation dispositions that mean "a human must STEER before this team's
140
+ * work can proceed": needs_intent (scope/direction/priority) and
141
+ * needs_clarification (ambiguity to resolve). These are exactly the two the
142
+ * escalation tool documents as answerable via the `answer` field -- a DIRECTED
143
+ * question the daemon reads back to the asking agent, distinct from the
144
+ * operator-hold dispositions (needs_operator / external_wait, a blocked-on-reality
145
+ * signal) and agent_resolvable (no human at all).
146
+ *
147
+ * Daemon-local literals for the same reason as OPERATOR_HOLD_DISPOSITIONS above:
148
+ * a bare `@telora/*` value import in a query module pulled into a mocked
149
+ * node:test fails to resolve under the module-mock loader. The canonical enum is
150
+ * packages/daemon-core/src/disposition.ts and the DB CHECK on
151
+ * agent_escalations.disposition is the real constraint; these strings must stay
152
+ * in sync with it.
153
+ */
154
+ export declare const DIRECTED_HOLD_DISPOSITIONS: readonly string[];
155
+ /**
156
+ * Returns the OPEN (pending|in_review) DIRECTED-hold escalation anchored to the
157
+ * given delivery, or null when none is open. Disposition-keyed sibling of
158
+ * findOpenOperatorHoldForDelivery, keyed on DIRECTED_HOLD_DISPOSITIONS
159
+ * (needs_intent / needs_clarification) instead of the operator-hold set.
160
+ *
161
+ * This is the vocabulary the completion-event no-progress guard previously
162
+ * lacked: a team parked on its own unanswered directed question could not be
163
+ * told apart from a team that has stalled, so the scope-coverage guard counted
164
+ * the wait as no-progress, re-engaged the team (real model spend), and
165
+ * eventually filed a team_failure ON TOP of the question.
166
+ *
167
+ * FAIL DIRECTION IS THE OPPOSITE of findOpenOperatorHoldForDelivery. The
168
+ * operator-hold gate's CALLER fails CLOSED (a lookup error => held) because a
169
+ * missed hold lets an operator-blocked delivery reach done. HERE the consuming
170
+ * guard must fail OPEN: a lookup error must NOT suppress a genuine stall
171
+ * escalation, so the caller treats an error as "not blocked". This function
172
+ * still reports what it finds and THROWS on a hard API error; the fail-open
173
+ * decision lives at the call site (completion/event-phases.computeCompletionFacts),
174
+ * which catches and defaults to not-blocked.
175
+ */
176
+ export declare function findOpenDirectedHoldForDelivery(deliveryId: string, focusId?: string): Promise<OperatorHoldEscalation | null>;
177
+ //# sourceMappingURL=holds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"holds.d.ts","sourceRoot":"","sources":["../../src/queries/holds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,yEAAyE;AACzE,eAAO,MAAM,wBAAwB,EAAE,WAAW,CAAC,MAAM,CAAqC,CAAC;AAE/F;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EAGvD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,eAAO,MAAM,4BAA4B,EAAE,SAAS,MAAM,EAEzD,CAAC;AAEF,mFAAmF;AACnF,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,+BAA+B,CACnD,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CASxC;AAED;;;GAGG;AACH,wBAAsB,8BAA8B,CAClD,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC,CAElB;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EAGvD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,+BAA+B,CACnD,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAExC"}
@@ -0,0 +1,232 @@
1
+ /**
2
+ * Delivery hold-lookup queries.
3
+ *
4
+ * "Is something holding this delivery out of done, and what?" -- the escalation
5
+ * side of that question. Two disposition-keyed families live here:
6
+ *
7
+ * - OPERATOR holds (needs_operator / external_wait): a human or an external
8
+ * party must act before the declared work counts as real. Fails CLOSED at
9
+ * its call site.
10
+ * - DIRECTED holds (needs_intent / needs_clarification): an unanswered
11
+ * question the daemon reads back to the asking agent. Fails OPEN at its
12
+ * call site.
13
+ *
14
+ * Plus SELF_REPORT_STALL_HOLD_KINDS: the kinds that are machine-filed alarms
15
+ * ABOUT a delivery's own cycling, excluded from the operator predicate so an
16
+ * alarm cannot constitute the condition it reports.
17
+ *
18
+ * Extracted from queries/issues.ts to keep that file under the daemon
19
+ * file-size limit -- the self-referential-alarm fix pushed it to 844. Bodies
20
+ * verbatim; issues.ts re-exports this surface so existing importers are
21
+ * unaffected.
22
+ *
23
+ * @module queries/holds
24
+ */
25
+ import { callApi } from './shared.js';
26
+ /** Escalation statuses that count as OPEN for every hold lookup here. */
27
+ export const OPEN_ESCALATION_STATUSES = new Set(['pending', 'in_review']);
28
+ /**
29
+ * The escalation dispositions that mean "a human operator or an external party
30
+ * must act before this delivery's declared work can be considered real":
31
+ * needs_operator (operator/infra/security action) and external_wait (blocked on
32
+ * a third party). Distinct from needs_intent / needs_clarification (a steering
33
+ * question, not a blocked-on-reality signal) and agent_resolvable (no human at
34
+ * all). Keyed on the DISPOSITION axis so ANY escalation kind carrying one of
35
+ * these holds its delivery -- the gate must not enumerate kinds.
36
+ *
37
+ * Declared as daemon-local string literals (not imported from @telora/daemon-core's
38
+ * ESCALATION_DISPOSITIONS) on purpose, mirroring MERGE_CONFLICT_ESCALATION_KIND
39
+ * below: a bare `@telora/*` VALUE import in a query module pulled into a mocked
40
+ * node:test fails to resolve under the module-mock loader (the daemon-local-copy
41
+ * rule). The canonical enum lives in packages/daemon-core/src/disposition.ts and
42
+ * the DB CHECK on agent_escalations.disposition is the real constraint; these
43
+ * strings must stay in sync with it.
44
+ */
45
+ export const OPERATOR_HOLD_DISPOSITIONS = [
46
+ 'needs_operator',
47
+ 'external_wait',
48
+ ];
49
+ /**
50
+ * escalation_kind discriminators that are SELF-REFERENTIAL stall alarms: a
51
+ * machine-filed escalation ABOUT a delivery's own cycling, which must NOT be
52
+ * allowed to satisfy the operator-hold predicate that holds that same delivery.
53
+ *
54
+ * The fixpoint this removes (observed 2026-07-26, delivery 50131436, escalations
55
+ * 96262dfa -> 43c4dade): the verify_failed cap detector files
56
+ * verify_gate_unclearable (disposition needs_operator, anchored to the delivery)
57
+ * when iteration_count exceeds the cap. findOpenOperatorHoldForDelivery matched
58
+ * on disposition ONLY, so that alarm satisfied the very hold predicate it was
59
+ * raised about; the delivery was held out of `done`; `done` is the only
60
+ * non-cancelled terminal that makes exceedsVerifyFailedCap stop firing; and
61
+ * iteration_count is monotonic -- so the alarm blocked the only exit that would
62
+ * silence it, and resolving one let the detector file the next on the following
63
+ * tick.
64
+ *
65
+ * ENUMERATION -- every machine-filed, delivery-anchored needs_operator kind, and
66
+ * whether it is a genuine hold or a self-referential stall alarm. The exclusion
67
+ * criterion is narrow and precise: exclude a kind IFF (a) it re-arms while the
68
+ * delivery is non-terminal AND (b) its ONLY silencing is the delivery reaching
69
+ * the terminal state the hold blocks. A kind that describes external reality an
70
+ * operator must change, or that is filed once and silenced by operator
71
+ * resolution, is a GENUINE hold and stays.
72
+ *
73
+ * verify_gate_unclearable (stall-detectors.ts) -- SELF-REFERENTIAL. Trigger
74
+ * (iteration_count) is monotonic and re-arms every tick while non-terminal;
75
+ * silenced only by done/cancelled, which the hold blocks. EXCLUDE.
76
+ * verify_evidence_unavailable (verification-feedback.ts) -- self-REPORT of an
77
+ * instrument fault, but filed ONCE per delivery (idempotent, never re-armed)
78
+ * and silenced by operator resolution, not by `done`. It also already holds
79
+ * the delivery via its OWN gate_state.blocking guard, so it does not lean on
80
+ * this predicate. Not a fixpoint -> KEEP as a hold.
81
+ * schema_drift_blocked (listener-auto-advance.ts) -- operator must apply a
82
+ * migration (external reality). KEEP.
83
+ * advance_blocked (delivery-advance-block.ts) -- dirty worktree / lockfile
84
+ * state an operator or agent must resolve. KEEP.
85
+ * cd_push_failed (ci-escalation.ts) / ci_run_red (ci-sensor-loop.ts) --
86
+ * external CI/CD state. KEEP.
87
+ * propagation_stale (staleness-sensor.ts) -- external propagation state. KEEP.
88
+ *
89
+ * (Focus-anchored kinds -- merge_conflict, merge_refused_dirty,
90
+ * review_window_stalled, stuck_focus_branch -- are never matched by
91
+ * findOpenOperatorHoldForDelivery, which keys on deliveryId, so they need no
92
+ * exclusion here.)
93
+ *
94
+ * Daemon-local literal for the same reason as OPERATOR_HOLD_DISPOSITIONS above:
95
+ * a bare `@telora/*` value import mis-resolves under the node:test module-mock
96
+ * loader, and importing stall-detectors.VERIFY_GATE_UNCLEARABLE_KIND would also
97
+ * form an import cycle (stall-detectors imports from this module). Keep in sync
98
+ * with stall-detectors.VERIFY_GATE_UNCLEARABLE_KIND and the DB CHECK.
99
+ */
100
+ export const SELF_REPORT_STALL_HOLD_KINDS = [
101
+ 'verify_gate_unclearable',
102
+ ];
103
+ /**
104
+ * Returns the OPEN (pending|in_review) operator-hold escalation anchored to the
105
+ * given delivery, or null when none is open.
106
+ *
107
+ * DISPOSITION-keyed sibling of hasOpenEscalationForDelivery (which is KIND-keyed):
108
+ * it matches ANY escalation_kind whose disposition is in OPERATOR_HOLD_DISPOSITIONS
109
+ * (needs_operator / external_wait). This is the vocabulary the verify->done gate
110
+ * previously lacked -- an operator blocked ON a delivery (e.g. "the host restore
111
+ * was NOT executed") could not hold that delivery out of done, so a clean review
112
+ * auto-approved it. Returning the matching row (id + kind + disposition), not a
113
+ * bare boolean, lets the gate write the block into the delivery's gate_state.
114
+ *
115
+ * Matches on the typed delivery_id + disposition COLUMNS in preference to the
116
+ * metadata bag, with a metadata fallback (metadata.deliveryId / metadata.disposition)
117
+ * for rows already open at deploy time. The status is re-checked client-side as
118
+ * defense-in-depth against a deploy-lagged edge fn returning resolved rows.
119
+ *
120
+ * escalation_list has NO server-side delivery_id filter, so the delivery match is
121
+ * applied client-side over the org's open rows. Pass `focusId` to narrow the page
122
+ * server-side (the same busy-org paging concern hasOpenWorktreeDirtyEscalation
123
+ * addresses); omit it and the lookup reads the newest 500 open org rows.
124
+ *
125
+ * FAIL-CLOSED is the CALLER's responsibility. This function reports what it finds
126
+ * and THROWS on a hard API error. The verify->done gate that consumes it exists
127
+ * precisely to fail closed, so it must treat a lookup error as "held" -- the
128
+ * opposite of the other escalation lookups (dedup/auto-close), which fail OPEN
129
+ * because a spurious park is worse than a missed dedup. Here a missed hold lets an
130
+ * operator-blocked delivery reach done, which is the failure this gate prevents.
131
+ */
132
+ export async function findOpenOperatorHoldForDelivery(deliveryId, focusId) {
133
+ return findOpenHoldForDelivery(deliveryId, OPERATOR_HOLD_DISPOSITIONS, focusId,
134
+ // A machine-filed alarm ABOUT this delivery's own cycling must not satisfy
135
+ // the predicate that holds it -- see SELF_REPORT_STALL_HOLD_KINDS.
136
+ new Set(SELF_REPORT_STALL_HOLD_KINDS));
137
+ }
138
+ /**
139
+ * Boolean convenience over findOpenOperatorHoldForDelivery for call sites that
140
+ * only need to know whether the hold exists (not which escalation it is).
141
+ */
142
+ export async function hasOpenOperatorHoldForDelivery(deliveryId, focusId) {
143
+ return (await findOpenOperatorHoldForDelivery(deliveryId, focusId)) !== null;
144
+ }
145
+ /**
146
+ * The escalation dispositions that mean "a human must STEER before this team's
147
+ * work can proceed": needs_intent (scope/direction/priority) and
148
+ * needs_clarification (ambiguity to resolve). These are exactly the two the
149
+ * escalation tool documents as answerable via the `answer` field -- a DIRECTED
150
+ * question the daemon reads back to the asking agent, distinct from the
151
+ * operator-hold dispositions (needs_operator / external_wait, a blocked-on-reality
152
+ * signal) and agent_resolvable (no human at all).
153
+ *
154
+ * Daemon-local literals for the same reason as OPERATOR_HOLD_DISPOSITIONS above:
155
+ * a bare `@telora/*` value import in a query module pulled into a mocked
156
+ * node:test fails to resolve under the module-mock loader. The canonical enum is
157
+ * packages/daemon-core/src/disposition.ts and the DB CHECK on
158
+ * agent_escalations.disposition is the real constraint; these strings must stay
159
+ * in sync with it.
160
+ */
161
+ export const DIRECTED_HOLD_DISPOSITIONS = [
162
+ 'needs_intent',
163
+ 'needs_clarification',
164
+ ];
165
+ /**
166
+ * Returns the OPEN (pending|in_review) DIRECTED-hold escalation anchored to the
167
+ * given delivery, or null when none is open. Disposition-keyed sibling of
168
+ * findOpenOperatorHoldForDelivery, keyed on DIRECTED_HOLD_DISPOSITIONS
169
+ * (needs_intent / needs_clarification) instead of the operator-hold set.
170
+ *
171
+ * This is the vocabulary the completion-event no-progress guard previously
172
+ * lacked: a team parked on its own unanswered directed question could not be
173
+ * told apart from a team that has stalled, so the scope-coverage guard counted
174
+ * the wait as no-progress, re-engaged the team (real model spend), and
175
+ * eventually filed a team_failure ON TOP of the question.
176
+ *
177
+ * FAIL DIRECTION IS THE OPPOSITE of findOpenOperatorHoldForDelivery. The
178
+ * operator-hold gate's CALLER fails CLOSED (a lookup error => held) because a
179
+ * missed hold lets an operator-blocked delivery reach done. HERE the consuming
180
+ * guard must fail OPEN: a lookup error must NOT suppress a genuine stall
181
+ * escalation, so the caller treats an error as "not blocked". This function
182
+ * still reports what it finds and THROWS on a hard API error; the fail-open
183
+ * decision lives at the call site (completion/event-phases.computeCompletionFacts),
184
+ * which catches and defaults to not-blocked.
185
+ */
186
+ export async function findOpenDirectedHoldForDelivery(deliveryId, focusId) {
187
+ return findOpenHoldForDelivery(deliveryId, DIRECTED_HOLD_DISPOSITIONS, focusId);
188
+ }
189
+ /**
190
+ * Shared body for the disposition-keyed open-hold lookups
191
+ * (findOpenOperatorHoldForDelivery / findOpenDirectedHoldForDelivery). Reads the
192
+ * newest 500 open (pending|in_review) escalations -- narrowed server-side by
193
+ * focusId when supplied, the same busy-org paging concern the sibling lookups
194
+ * address -- and returns the first whose delivery matches (typed delivery_id
195
+ * COLUMN preferred, metadata.deliveryId fallback for rows open at deploy time)
196
+ * AND whose disposition (typed column preferred, metadata fallback) is in the
197
+ * given set. Status is re-checked client-side as defense-in-depth against a
198
+ * deploy-lagged edge fn returning resolved rows. THROWS on a hard API error;
199
+ * fail-open/closed is the CALLER's choice.
200
+ *
201
+ * `excludeKinds` (optional) drops any otherwise-matching escalation whose
202
+ * escalation_kind is in the set BEFORE it is returned -- used by the operator-hold
203
+ * lookup to skip self-referential stall alarms (SELF_REPORT_STALL_HOLD_KINDS) so an
204
+ * alarm about a delivery's own cycling cannot hold that delivery. The kind is read
205
+ * from the typed column with a metadata.kind fallback (parity with the disposition
206
+ * fallback), so an excluded kind is dropped regardless of column promotion.
207
+ */
208
+ async function findOpenHoldForDelivery(deliveryId, dispositions, focusId, excludeKinds) {
209
+ const holdSet = new Set(dispositions);
210
+ const fields = { statuses: ['pending', 'in_review'] };
211
+ if (focusId)
212
+ fields.focusId = focusId;
213
+ const result = await callApi('escalation_list', { fields, limit: 500 });
214
+ for (const e of result.escalations ?? []) {
215
+ if (e.status && !OPEN_ESCALATION_STATUSES.has(e.status))
216
+ continue;
217
+ const meta = e.metadata ?? null;
218
+ const disposition = (typeof e.disposition === 'string' ? e.disposition : null) ??
219
+ (typeof meta?.disposition === 'string' ? meta.disposition : null);
220
+ const matchedDelivery = e.deliveryId === deliveryId || meta?.deliveryId === deliveryId;
221
+ if (matchedDelivery && disposition !== null && holdSet.has(disposition)) {
222
+ const kind = (typeof e.escalationKind === 'string' ? e.escalationKind : null) ??
223
+ (typeof meta?.kind === 'string' ? meta.kind : null);
224
+ // A self-referential stall alarm about this delivery must not hold it.
225
+ if (excludeKinds && kind !== null && excludeKinds.has(kind))
226
+ continue;
227
+ return { id: e.id, escalationKind: e.escalationKind ?? null, disposition };
228
+ }
229
+ }
230
+ return null;
231
+ }
232
+ //# sourceMappingURL=holds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"holds.js","sourceRoot":"","sources":["../../src/queries/holds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,yEAAyE;AACzE,MAAM,CAAC,MAAM,wBAAwB,GAAwB,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;AAE/F;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAsB;IAC3D,gBAAgB;IAChB,eAAe;CAChB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAsB;IAC7D,yBAAyB;CAC1B,CAAC;AASF;;;;;;;;;;;;;;;;;;;;;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,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC;YAAE,SAAS;QAClE,MAAM,IAAI,GAAI,CAAC,CAAC,QAA2C,IAAI,IAAI,CAAC;QACpE,MAAM,WAAW,GACf,CAAC,OAAO,CAAC,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;YAC1D,CAAC,OAAO,IAAI,EAAE,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACpE,MAAM,eAAe,GACnB,CAAC,CAAC,UAAU,KAAK,UAAU,IAAI,IAAI,EAAE,UAAU,KAAK,UAAU,CAAC;QACjE,IAAI,eAAe,IAAI,WAAW,KAAK,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACxE,MAAM,IAAI,GACR,CAAC,OAAO,CAAC,CAAC,cAAc,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC;gBAChE,CAAC,OAAO,IAAI,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAE,IAAI,CAAC,IAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAClE,uEAAuE;YACvE,IAAI,YAAY,IAAI,IAAI,KAAK,IAAI,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC;gBAAE,SAAS;YACtE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC,cAAc,IAAI,IAAI,EAAE,WAAW,EAAE,CAAC;QAC7E,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -147,104 +147,9 @@ export declare function hasOpenTeamFailureEscalation(focusId: string): Promise<b
147
147
  * polls files exactly one open escalation instead of one per tick.
148
148
  */
149
149
  export declare function hasOpenEscalationForDelivery(deliveryId: string, escalationKind: string): Promise<boolean>;
150
- /**
151
- * The escalation dispositions that mean "a human operator or an external party
152
- * must act before this delivery's declared work can be considered real":
153
- * needs_operator (operator/infra/security action) and external_wait (blocked on
154
- * a third party). Distinct from needs_intent / needs_clarification (a steering
155
- * question, not a blocked-on-reality signal) and agent_resolvable (no human at
156
- * all). Keyed on the DISPOSITION axis so ANY escalation kind carrying one of
157
- * these holds its delivery -- the gate must not enumerate kinds.
158
- *
159
- * Declared as daemon-local string literals (not imported from @telora/daemon-core's
160
- * ESCALATION_DISPOSITIONS) on purpose, mirroring MERGE_CONFLICT_ESCALATION_KIND
161
- * below: a bare `@telora/*` VALUE import in a query module pulled into a mocked
162
- * node:test fails to resolve under the module-mock loader (the daemon-local-copy
163
- * rule). The canonical enum lives in packages/daemon-core/src/disposition.ts and
164
- * the DB CHECK on agent_escalations.disposition is the real constraint; these
165
- * strings must stay in sync with it.
166
- */
167
- export declare const OPERATOR_HOLD_DISPOSITIONS: readonly string[];
168
- /** The open operator-hold escalation a delivery is blocked on (for gate_state). */
169
- export interface OperatorHoldEscalation {
170
- id: string;
171
- escalationKind: string | null;
172
- disposition: string;
173
- }
174
- /**
175
- * Returns the OPEN (pending|in_review) operator-hold escalation anchored to the
176
- * given delivery, or null when none is open.
177
- *
178
- * DISPOSITION-keyed sibling of hasOpenEscalationForDelivery (which is KIND-keyed):
179
- * it matches ANY escalation_kind whose disposition is in OPERATOR_HOLD_DISPOSITIONS
180
- * (needs_operator / external_wait). This is the vocabulary the verify->done gate
181
- * previously lacked -- an operator blocked ON a delivery (e.g. "the host restore
182
- * was NOT executed") could not hold that delivery out of done, so a clean review
183
- * auto-approved it. Returning the matching row (id + kind + disposition), not a
184
- * bare boolean, lets the gate write the block into the delivery's gate_state.
185
- *
186
- * Matches on the typed delivery_id + disposition COLUMNS in preference to the
187
- * metadata bag, with a metadata fallback (metadata.deliveryId / metadata.disposition)
188
- * for rows already open at deploy time. The status is re-checked client-side as
189
- * defense-in-depth against a deploy-lagged edge fn returning resolved rows.
190
- *
191
- * escalation_list has NO server-side delivery_id filter, so the delivery match is
192
- * applied client-side over the org's open rows. Pass `focusId` to narrow the page
193
- * server-side (the same busy-org paging concern hasOpenWorktreeDirtyEscalation
194
- * addresses); omit it and the lookup reads the newest 500 open org rows.
195
- *
196
- * FAIL-CLOSED is the CALLER's responsibility. This function reports what it finds
197
- * and THROWS on a hard API error. The verify->done gate that consumes it exists
198
- * precisely to fail closed, so it must treat a lookup error as "held" -- the
199
- * opposite of the other escalation lookups (dedup/auto-close), which fail OPEN
200
- * because a spurious park is worse than a missed dedup. Here a missed hold lets an
201
- * operator-blocked delivery reach done, which is the failure this gate prevents.
202
- */
203
- export declare function findOpenOperatorHoldForDelivery(deliveryId: string, focusId?: string): Promise<OperatorHoldEscalation | null>;
204
- /**
205
- * Boolean convenience over findOpenOperatorHoldForDelivery for call sites that
206
- * only need to know whether the hold exists (not which escalation it is).
207
- */
208
- export declare function hasOpenOperatorHoldForDelivery(deliveryId: string, focusId?: string): Promise<boolean>;
209
- /**
210
- * The escalation dispositions that mean "a human must STEER before this team's
211
- * work can proceed": needs_intent (scope/direction/priority) and
212
- * needs_clarification (ambiguity to resolve). These are exactly the two the
213
- * escalation tool documents as answerable via the `answer` field -- a DIRECTED
214
- * question the daemon reads back to the asking agent, distinct from the
215
- * operator-hold dispositions (needs_operator / external_wait, a blocked-on-reality
216
- * signal) and agent_resolvable (no human at all).
217
- *
218
- * Daemon-local literals for the same reason as OPERATOR_HOLD_DISPOSITIONS above:
219
- * a bare `@telora/*` value import in a query module pulled into a mocked
220
- * node:test fails to resolve under the module-mock loader. The canonical enum is
221
- * packages/daemon-core/src/disposition.ts and the DB CHECK on
222
- * agent_escalations.disposition is the real constraint; these strings must stay
223
- * in sync with it.
224
- */
225
- export declare const DIRECTED_HOLD_DISPOSITIONS: readonly string[];
226
- /**
227
- * Returns the OPEN (pending|in_review) DIRECTED-hold escalation anchored to the
228
- * given delivery, or null when none is open. Disposition-keyed sibling of
229
- * findOpenOperatorHoldForDelivery, keyed on DIRECTED_HOLD_DISPOSITIONS
230
- * (needs_intent / needs_clarification) instead of the operator-hold set.
231
- *
232
- * This is the vocabulary the completion-event no-progress guard previously
233
- * lacked: a team parked on its own unanswered directed question could not be
234
- * told apart from a team that has stalled, so the scope-coverage guard counted
235
- * the wait as no-progress, re-engaged the team (real model spend), and
236
- * eventually filed a team_failure ON TOP of the question.
237
- *
238
- * FAIL DIRECTION IS THE OPPOSITE of findOpenOperatorHoldForDelivery. The
239
- * operator-hold gate's CALLER fails CLOSED (a lookup error => held) because a
240
- * missed hold lets an operator-blocked delivery reach done. HERE the consuming
241
- * guard must fail OPEN: a lookup error must NOT suppress a genuine stall
242
- * escalation, so the caller treats an error as "not blocked". This function
243
- * still reports what it finds and THROWS on a hard API error; the fail-open
244
- * decision lives at the call site (completion/event-phases.computeCompletionFacts),
245
- * which catches and defaults to not-blocked.
246
- */
247
- export declare function findOpenDirectedHoldForDelivery(deliveryId: string, focusId?: string): Promise<OperatorHoldEscalation | null>;
150
+ import { OPERATOR_HOLD_DISPOSITIONS, SELF_REPORT_STALL_HOLD_KINDS, DIRECTED_HOLD_DISPOSITIONS, findOpenOperatorHoldForDelivery, hasOpenOperatorHoldForDelivery, findOpenDirectedHoldForDelivery, type OperatorHoldEscalation } from './holds.js';
151
+ export { OPERATOR_HOLD_DISPOSITIONS, SELF_REPORT_STALL_HOLD_KINDS, DIRECTED_HOLD_DISPOSITIONS, findOpenOperatorHoldForDelivery, hasOpenOperatorHoldForDelivery, findOpenDirectedHoldForDelivery, };
152
+ export type { OperatorHoldEscalation };
248
153
  /**
249
154
  * escalation_kind discriminators for the two focus-merge worktree-dirty
250
155
  * classes. Declared as daemon-local string constants (not imported from
@@ -348,6 +253,44 @@ export declare function hasOpenFocusEscalation(focusId: string, escalationKind:
348
253
  * worktree), and a successful merge clears merge_conflict.
349
254
  */
350
255
  export declare function resolveOpenWorktreeDirtyEscalations(focusId: string, kinds: readonly string[], resolutionNotes?: string): Promise<number>;
256
+ /** An open agent_resolvable filing the daemon hands to a focus's next spawn. */
257
+ export interface AgentResolvableItem {
258
+ id: string;
259
+ escalationKind: string | null;
260
+ description: string;
261
+ createdAt: string;
262
+ }
263
+ /** Minimal escalation row shape the agent_resolvable filter reads. */
264
+ export interface AgentResolvableEscalationRow {
265
+ id: string;
266
+ status?: string | null;
267
+ disposition?: string | null;
268
+ escalationKind?: string | null;
269
+ description?: string | null;
270
+ createdAt?: string | null;
271
+ }
272
+ /**
273
+ * Pure: keep only the OPEN, agent_resolvable rows and shape them into
274
+ * AgentResolvableItems. The status re-check is defense-in-depth so a
275
+ * resolved/dismissed row can never ride into a spawn even if the fetch returned
276
+ * one. Exported for direct unit testing (no callApi mocking needed).
277
+ */
278
+ export declare function toAgentResolvableItems(rows: readonly AgentResolvableEscalationRow[]): AgentResolvableItem[];
279
+ /**
280
+ * List the OPEN (pending/in_review) agent_resolvable escalations anchored to a
281
+ * focus -- the filings a machine (the next spawned team) can resolve without a
282
+ * human. This is how the daemon CONSUMES agent_resolvable filings: it hands them
283
+ * to the focus's next execution spawn (ride-into-next-spawn) so the agent
284
+ * addresses them as part of its work, and on a clean exit they auto-resolve.
285
+ * agent_resolvable rows are hidden from the operator inbox (the disposition
286
+ * routes to the machine, not the human); this is the machine-side counterpart read.
287
+ *
288
+ * escalation_list does not filter by disposition server-side, so we narrow
289
+ * server-side by focusId + open statuses (scoping the 500-row page to this focus)
290
+ * and filter disposition === agent_resolvable client-side. The status re-check is
291
+ * defense-in-depth so a resolved/dismissed row can never ride into a spawn.
292
+ */
293
+ export declare function listOpenAgentResolvableForFocus(focusId: string): Promise<AgentResolvableItem[]>;
351
294
  /**
352
295
  * Returns true when an OPEN (status pending or in_review) PRD machine escalation
353
296
  * of the given `discriminator` already exists for the given PRD.
@@ -382,5 +325,4 @@ export declare function markEscalationResolved(escalationId: string, resolutionN
382
325
  * Create an issue on a delivery (for create_issue trigger action).
383
326
  */
384
327
  export declare function createIssue(deliveryId: string, title: string, description: string | null, issueType: string, priority: string | null): Promise<string>;
385
- export {};
386
328
  //# sourceMappingURL=issues.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"issues.d.ts","sourceRoot":"","sources":["../../src/queries/issues.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAIL,mBAAmB,EACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACvF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,KAAK,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEpD;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAO/E;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOjF;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYtF;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,uHAAuH;IACvH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC;;;;;OAKG;IACH,SAAS,CAAC,E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