@oscharko-dev/keiko-contracts 0.2.8 → 0.2.9

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 (106) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/bff-wire.d.ts +33 -0
  3. package/dist/bff-wire.d.ts.map +1 -1
  4. package/dist/command-runner.d.ts +81 -0
  5. package/dist/command-runner.d.ts.map +1 -0
  6. package/dist/command-runner.js +209 -0
  7. package/dist/container-runtime.d.ts +125 -0
  8. package/dist/container-runtime.d.ts.map +1 -0
  9. package/dist/container-runtime.js +287 -0
  10. package/dist/context-engineering.js +2 -2
  11. package/dist/discussion-intelligence.d.ts +70 -0
  12. package/dist/discussion-intelligence.d.ts.map +1 -0
  13. package/dist/discussion-intelligence.js +440 -0
  14. package/dist/editor-agent-governance.d.ts +65 -0
  15. package/dist/editor-agent-governance.d.ts.map +1 -0
  16. package/dist/editor-agent-governance.js +180 -0
  17. package/dist/editor-agent.d.ts +29 -1
  18. package/dist/editor-agent.d.ts.map +1 -1
  19. package/dist/editor-agent.js +183 -6
  20. package/dist/editor-builtin-capabilities.d.ts +13 -0
  21. package/dist/editor-builtin-capabilities.d.ts.map +1 -0
  22. package/dist/editor-builtin-capabilities.js +135 -0
  23. package/dist/editor-language-mode-map.d.ts +11 -0
  24. package/dist/editor-language-mode-map.d.ts.map +1 -0
  25. package/dist/editor-language-mode-map.js +89 -0
  26. package/dist/editor-layout.d.ts +37 -0
  27. package/dist/editor-layout.d.ts.map +1 -1
  28. package/dist/editor-layout.js +125 -8
  29. package/dist/editor-workspace-path.d.ts +20 -0
  30. package/dist/editor-workspace-path.d.ts.map +1 -0
  31. package/dist/editor-workspace-path.js +133 -0
  32. package/dist/evidence.d.ts +3 -1
  33. package/dist/evidence.d.ts.map +1 -1
  34. package/dist/gateway.d.ts +72 -3
  35. package/dist/gateway.d.ts.map +1 -1
  36. package/dist/gateway.js +73 -3
  37. package/dist/git-commit-intent.d.ts +28 -0
  38. package/dist/git-commit-intent.d.ts.map +1 -0
  39. package/dist/git-commit-intent.js +155 -0
  40. package/dist/git-commit-policy.d.ts +29 -0
  41. package/dist/git-commit-policy.d.ts.map +1 -0
  42. package/dist/git-commit-policy.js +173 -0
  43. package/dist/git-delivery-action-sheet.d.ts +157 -0
  44. package/dist/git-delivery-action-sheet.d.ts.map +1 -0
  45. package/dist/git-delivery-action-sheet.js +430 -0
  46. package/dist/git-delivery-evidence.d.ts +92 -0
  47. package/dist/git-delivery-evidence.d.ts.map +1 -0
  48. package/dist/git-delivery-evidence.js +272 -0
  49. package/dist/git-delivery-policy.d.ts +40 -0
  50. package/dist/git-delivery-policy.d.ts.map +1 -0
  51. package/dist/git-delivery-policy.js +183 -0
  52. package/dist/git-delivery-provider.d.ts +53 -0
  53. package/dist/git-delivery-provider.d.ts.map +1 -0
  54. package/dist/git-delivery-provider.js +96 -0
  55. package/dist/git-delivery.d.ts +202 -0
  56. package/dist/git-delivery.d.ts.map +1 -0
  57. package/dist/git-delivery.js +410 -0
  58. package/dist/git-history.d.ts +27 -0
  59. package/dist/git-history.d.ts.map +1 -0
  60. package/dist/git-history.js +73 -0
  61. package/dist/git-merge.d.ts +67 -0
  62. package/dist/git-merge.d.ts.map +1 -0
  63. package/dist/git-merge.js +323 -0
  64. package/dist/git-pull-request.d.ts +112 -0
  65. package/dist/git-pull-request.d.ts.map +1 -0
  66. package/dist/git-pull-request.js +351 -0
  67. package/dist/git-repository-agent.d.ts +46 -0
  68. package/dist/git-repository-agent.d.ts.map +1 -0
  69. package/dist/git-repository-agent.js +198 -0
  70. package/dist/git-repository-summary.d.ts +54 -0
  71. package/dist/git-repository-summary.d.ts.map +1 -0
  72. package/dist/git-repository-summary.js +105 -0
  73. package/dist/git-repository.d.ts +60 -0
  74. package/dist/git-repository.d.ts.map +1 -0
  75. package/dist/git-repository.js +106 -0
  76. package/dist/git-sync.d.ts +49 -0
  77. package/dist/git-sync.d.ts.map +1 -0
  78. package/dist/git-sync.js +110 -0
  79. package/dist/index.d.ts +63 -9
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +33 -6
  82. package/dist/lsp-process.d.ts +38 -0
  83. package/dist/lsp-process.d.ts.map +1 -0
  84. package/dist/lsp-process.js +103 -0
  85. package/dist/runtime-capabilities.d.ts +44 -0
  86. package/dist/runtime-capabilities.d.ts.map +1 -0
  87. package/dist/runtime-capabilities.js +141 -0
  88. package/dist/task-workspace.d.ts +302 -0
  89. package/dist/task-workspace.d.ts.map +1 -0
  90. package/dist/task-workspace.js +1236 -0
  91. package/dist/voice-action-intent.d.ts +86 -0
  92. package/dist/voice-action-intent.d.ts.map +1 -0
  93. package/dist/voice-action-intent.js +387 -0
  94. package/dist/voice-playback.d.ts +50 -0
  95. package/dist/voice-playback.d.ts.map +1 -0
  96. package/dist/voice-playback.js +240 -0
  97. package/dist/voice-protocol.d.ts +165 -0
  98. package/dist/voice-protocol.d.ts.map +1 -0
  99. package/dist/voice-protocol.js +312 -0
  100. package/dist/voice-transcript.d.ts +57 -0
  101. package/dist/voice-transcript.d.ts.map +1 -0
  102. package/dist/voice-transcript.js +221 -0
  103. package/package.json +5 -1
  104. package/dist/conversation-budget.d.ts +0 -37
  105. package/dist/conversation-budget.d.ts.map +0 -1
  106. package/dist/conversation-budget.js +0 -97
@@ -0,0 +1,430 @@
1
+ // UI-safe approval and preview contracts for the governed Git delivery surface (Issue #473,
2
+ // Epic #470). Ownership: git-delivery-action-sheet domain — the presentation projection that turns
3
+ // the kernel's content-free facts (the #471 contract envelope + #472 lifecycle outputs) into a
4
+ // consistent, UI-safe action sheet. Disjoint from git-delivery.ts (action model + risk + envelope),
5
+ // git-delivery-policy.ts (policy evaluator), and git-delivery-provider.ts (provider-neutral state).
6
+ //
7
+ // Leaf-package rules (ADR-0019, ADR-0060): pure types and frozen const tables and pure functions
8
+ // only. No IO, no clock, no crypto, no randomness. Relative imports end in ".js" and reference only
9
+ // the git-delivery sibling atoms — never a kernel (keiko-tools) type. The kernel's preflight finding
10
+ // codes are a keiko-tools concern; they reach this layer only as opaque, closed-vocabulary display
11
+ // keys (GitDeliveryExpectedBlocker.reasonCode), never as a type this leaf re-enumerates. All
12
+ // behavioural meaning is carried by typed fields (source/severity/remediation/cause/state), never
13
+ // inferred from a string — satisfying the issue's Engineering Note.
14
+ //
15
+ // This module is content-free: it carries counts, flags, branch names, and typed codes only. It
16
+ // never carries diff content, file paths, secrets, command strings, or raw subprocess output.
17
+ import { GIT_DELIVERY_RISK_CLASS_SEVERITY, gitDeliveryRiskClassForInputs, isGitDeliveryActionKind, isGitDeliveryBlockReason, isGitDeliveryConstraint, isGitDeliveryRecoveryStrategyHint, isGitDeliveryRiskClass, } from "./git-delivery.js";
18
+ import { isGitDeliveryBranchProtection, isGitDeliveryChecksState, isGitDeliveryMergeReadiness, isGitDeliveryPullRequestState, } from "./git-delivery-provider.js";
19
+ export const GIT_DELIVERY_ACTION_SHEET_SCHEMA_VERSION = "1";
20
+ export const GIT_DELIVERY_ACTION_SHEET_STATES = [
21
+ "ready-to-execute",
22
+ "waiting-for-approval",
23
+ "blocked",
24
+ ];
25
+ export const GIT_DELIVERY_APPROVAL_NECESSITIES = [
26
+ "not-required",
27
+ "required",
28
+ "impossible",
29
+ ];
30
+ export const GIT_DELIVERY_BLOCKED_CAUSES = [
31
+ "policy",
32
+ "preflight",
33
+ "provider-not-ready",
34
+ ];
35
+ export const GIT_DELIVERY_BLOCKER_SOURCES = [
36
+ "preflight",
37
+ "policy",
38
+ "provider",
39
+ ];
40
+ export const GIT_DELIVERY_BLOCKER_SEVERITIES = [
41
+ "blocking",
42
+ "advisory",
43
+ ];
44
+ export const GIT_DELIVERY_REMEDIATION_CLASSES = [
45
+ "user-actionable",
46
+ "internal",
47
+ ];
48
+ export const GIT_DELIVERY_RECOVERY_ACTION_HINTS = [
49
+ "retry",
50
+ "stage-changes",
51
+ "configure-upstream",
52
+ "resolve-conflicts",
53
+ "abort-in-progress-operation",
54
+ "request-approval",
55
+ "adjust-policy-target",
56
+ "recover-via-strategy",
57
+ "wait-for-provider",
58
+ ];
59
+ // ─── Private predicate helpers ───────────────────────────────────────────────────────
60
+ function isRecord(value) {
61
+ return typeof value === "object" && value !== null && !Array.isArray(value);
62
+ }
63
+ function isString(value) {
64
+ return typeof value === "string";
65
+ }
66
+ function isNonEmptyString(value) {
67
+ return typeof value === "string" && value.length > 0;
68
+ }
69
+ function isBoolean(value) {
70
+ return typeof value === "boolean";
71
+ }
72
+ function isNonNegativeInteger(value) {
73
+ return typeof value === "number" && Number.isInteger(value) && value >= 0;
74
+ }
75
+ function isStringArray(value) {
76
+ return Array.isArray(value) && value.every(isString);
77
+ }
78
+ function isUndefinedOr(check) {
79
+ return (v) => v === undefined || check(v);
80
+ }
81
+ function isInSet(set) {
82
+ return (v) => isString(v) && set.includes(v);
83
+ }
84
+ // ─── Exported enum guards ────────────────────────────────────────────────────────────
85
+ export const isGitDeliveryActionSheetState = isInSet(GIT_DELIVERY_ACTION_SHEET_STATES);
86
+ export const isGitDeliveryApprovalNecessity = isInSet(GIT_DELIVERY_APPROVAL_NECESSITIES);
87
+ export const isGitDeliveryBlockedCause = isInSet(GIT_DELIVERY_BLOCKED_CAUSES);
88
+ export const isGitDeliveryBlockerSource = isInSet(GIT_DELIVERY_BLOCKER_SOURCES);
89
+ export const isGitDeliveryBlockerSeverity = isInSet(GIT_DELIVERY_BLOCKER_SEVERITIES);
90
+ export const isGitDeliveryRemediationClass = isInSet(GIT_DELIVERY_REMEDIATION_CLASSES);
91
+ export const isGitDeliveryRecoveryActionHint = isInSet(GIT_DELIVERY_RECOVERY_ACTION_HINTS);
92
+ // ─── Exported structural guards ──────────────────────────────────────────────────────
93
+ export function isGitDeliveryExpectedBlocker(value) {
94
+ return (isRecord(value) &&
95
+ isGitDeliveryBlockerSource(value.source) &&
96
+ isGitDeliveryBlockerSeverity(value.severity) &&
97
+ isGitDeliveryRemediationClass(value.remediation) &&
98
+ isNonEmptyString(value.reasonCode));
99
+ }
100
+ export function isGitDeliveryRecoveryHint(value) {
101
+ if (!isRecord(value)) {
102
+ return false;
103
+ }
104
+ if (!isGitDeliveryRecoveryActionHint(value.actionHint)) {
105
+ return false;
106
+ }
107
+ if (!isGitDeliveryRemediationClass(value.remediation)) {
108
+ return false;
109
+ }
110
+ if (!isUndefinedOr(isGitDeliveryRecoveryStrategyHint)(value.suggestedRecoveryStrategy)) {
111
+ return false;
112
+ }
113
+ // A concrete strategy is only meaningful for the "recover-via-strategy" hint.
114
+ if (value.suggestedRecoveryStrategy !== undefined &&
115
+ value.actionHint !== "recover-via-strategy") {
116
+ return false;
117
+ }
118
+ return true;
119
+ }
120
+ export function isGitDeliveryApprovalSummary(value) {
121
+ return (isRecord(value) &&
122
+ isGitDeliveryApprovalNecessity(value.necessity) &&
123
+ isBoolean(value.satisfied) &&
124
+ isGitDeliveryRiskClass(value.riskClass) &&
125
+ isNonNegativeInteger(value.riskSeverity) &&
126
+ isStringArray(value.requiredApprovers));
127
+ }
128
+ export const GIT_DELIVERY_POLICY_DECISION_OUTCOMES = ["allowed", "blocked", "approval-gated", "constrained"];
129
+ export const isGitDeliveryPolicyDecisionOutcome = isInSet(GIT_DELIVERY_POLICY_DECISION_OUTCOMES);
130
+ export function isGitDeliveryPolicyExplanation(value) {
131
+ return (isRecord(value) &&
132
+ isGitDeliveryPolicyDecisionOutcome(value.decision) &&
133
+ isStringArray(value.requiredApprovers) &&
134
+ Array.isArray(value.constraints) &&
135
+ value.constraints.every(isGitDeliveryConstraint) &&
136
+ isUndefinedOr(isGitDeliveryBlockReason)(value.blockReason));
137
+ }
138
+ function isExpectedBlockerArray(value) {
139
+ return Array.isArray(value) && value.every(isGitDeliveryExpectedBlocker);
140
+ }
141
+ function previewProviderFieldsValid(value) {
142
+ return (isUndefinedOr(isGitDeliveryPullRequestState)(value.pullRequest) &&
143
+ isUndefinedOr(isGitDeliveryMergeReadiness)(value.mergeReadiness) &&
144
+ isUndefinedOr(isGitDeliveryBranchProtection)(value.branchProtection) &&
145
+ isUndefinedOr(isGitDeliveryChecksState)(value.checks));
146
+ }
147
+ function previewScalarFieldsValid(value) {
148
+ return (value.schemaVersion === GIT_DELIVERY_ACTION_SHEET_SCHEMA_VERSION &&
149
+ isGitDeliveryActionKind(value.actionKind) &&
150
+ isGitDeliveryRiskClass(value.riskClass) &&
151
+ isNonNegativeInteger(value.riskSeverity) &&
152
+ isUndefinedOr(isNonEmptyString)(value.affectedBranchName) &&
153
+ isUndefinedOr(isNonEmptyString)(value.baseBranchName) &&
154
+ isUndefinedOr(isNonEmptyString)(value.remoteBranchName) &&
155
+ isUndefinedOr(isNonNegativeInteger)(value.estimatedFileCount) &&
156
+ isUndefinedOr(isNonNegativeInteger)(value.estimatedBytesDelta));
157
+ }
158
+ function previewFlagFieldsValid(value) {
159
+ return (isBoolean(value.touchesRemote) &&
160
+ isBoolean(value.wouldCreateRemoteBranch) &&
161
+ isBoolean(value.wouldForcePublish) &&
162
+ isBoolean(value.wouldTriggerChecks));
163
+ }
164
+ export function isGitDeliveryPreviewManifest(value) {
165
+ return (isRecord(value) &&
166
+ previewScalarFieldsValid(value) &&
167
+ previewFlagFieldsValid(value) &&
168
+ previewProviderFieldsValid(value) &&
169
+ isExpectedBlockerArray(value.expectedBlockers));
170
+ }
171
+ export function isGitDeliveryBlockedDetail(value) {
172
+ return (isRecord(value) &&
173
+ isGitDeliveryBlockedCause(value.cause) &&
174
+ isExpectedBlockerArray(value.expectedBlockers));
175
+ }
176
+ function actionSheetCoreFieldsValid(value) {
177
+ return (value.schemaVersion === GIT_DELIVERY_ACTION_SHEET_SCHEMA_VERSION &&
178
+ isNonEmptyString(value.actionId) &&
179
+ isGitDeliveryActionKind(value.actionKind) &&
180
+ isGitDeliveryActionSheetState(value.state));
181
+ }
182
+ function actionSheetCompositeFieldsValid(value) {
183
+ return (isGitDeliveryPreviewManifest(value.preview) &&
184
+ isGitDeliveryApprovalSummary(value.approval) &&
185
+ isGitDeliveryPolicyExplanation(value.policyExplanation) &&
186
+ Array.isArray(value.recovery) &&
187
+ value.recovery.every(isGitDeliveryRecoveryHint) &&
188
+ isUndefinedOr(isGitDeliveryBlockedDetail)(value.blocked));
189
+ }
190
+ function actionSheetBlockedInvariant(value) {
191
+ // blocked detail present iff state is blocked.
192
+ return (value.state === "blocked") === (value.blocked !== undefined);
193
+ }
194
+ export function isGitDeliveryActionSheet(value) {
195
+ return (isRecord(value) &&
196
+ actionSheetCoreFieldsValid(value) &&
197
+ actionSheetCompositeFieldsValid(value) &&
198
+ actionSheetBlockedInvariant(value));
199
+ }
200
+ export function parseGitDeliveryActionSheet(value) {
201
+ if (!isGitDeliveryActionSheet(value)) {
202
+ return { ok: false, errors: ["value is not a valid GitDeliveryActionSheet"] };
203
+ }
204
+ return { ok: true, value };
205
+ }
206
+ // ─── Pure projection helpers ─────────────────────────────────────────────────────────
207
+ const REMOTE_ACTION_KINDS = [
208
+ "push",
209
+ "pr-create",
210
+ "pr-update",
211
+ "merge",
212
+ ];
213
+ function actionTouchesRemote(kind) {
214
+ return REMOTE_ACTION_KINDS.includes(kind);
215
+ }
216
+ function affectedBranchOf(inputs) {
217
+ switch (inputs.kind) {
218
+ case "branch-create":
219
+ case "branch-switch":
220
+ return inputs.branchName;
221
+ case "push":
222
+ return inputs.sourceBranchName;
223
+ case "pr-create":
224
+ case "pr-update":
225
+ return inputs.headBranchName;
226
+ default:
227
+ return undefined;
228
+ }
229
+ }
230
+ function baseBranchOf(inputs) {
231
+ switch (inputs.kind) {
232
+ case "branch-create":
233
+ case "pr-create":
234
+ case "pr-update":
235
+ return inputs.baseBranchName;
236
+ default:
237
+ return undefined;
238
+ }
239
+ }
240
+ function remoteBranchOf(inputs) {
241
+ return inputs.kind === "push" ? inputs.remoteBranchName : undefined;
242
+ }
243
+ function wouldForcePublishOf(inputs) {
244
+ return inputs.kind === "push" && inputs.forcePush;
245
+ }
246
+ function wouldCreateRemoteBranchOf(inputs, kernelPreview) {
247
+ if (inputs.kind === "push") {
248
+ return inputs.setUpstreamTracking;
249
+ }
250
+ return kernelPreview?.wouldCreateRemoteBranch ?? false;
251
+ }
252
+ function previewBranchAndScopeFields(inputs, kernelPreview) {
253
+ const out = {};
254
+ const affected = affectedBranchOf(inputs);
255
+ if (affected !== undefined) {
256
+ out.affectedBranchName = affected;
257
+ }
258
+ const base = baseBranchOf(inputs);
259
+ if (base !== undefined) {
260
+ out.baseBranchName = base;
261
+ }
262
+ const remote = remoteBranchOf(inputs);
263
+ if (remote !== undefined) {
264
+ out.remoteBranchName = remote;
265
+ }
266
+ if (kernelPreview?.estimatedFileCount !== undefined) {
267
+ out.estimatedFileCount = kernelPreview.estimatedFileCount;
268
+ }
269
+ if (kernelPreview?.estimatedBytesDelta !== undefined) {
270
+ out.estimatedBytesDelta = kernelPreview.estimatedBytesDelta;
271
+ }
272
+ return out;
273
+ }
274
+ function previewProviderFields(input) {
275
+ const out = {};
276
+ if (input.pullRequest !== undefined) {
277
+ out.pullRequest = input.pullRequest;
278
+ }
279
+ if (input.mergeReadiness !== undefined) {
280
+ out.mergeReadiness = input.mergeReadiness;
281
+ }
282
+ if (input.branchProtection !== undefined) {
283
+ out.branchProtection = input.branchProtection;
284
+ }
285
+ if (input.checks !== undefined) {
286
+ out.checks = input.checks;
287
+ }
288
+ return out;
289
+ }
290
+ export function buildGitDeliveryPreviewManifest(input) {
291
+ const { resolvedInputs, kernelPreview } = input;
292
+ const riskClass = gitDeliveryRiskClassForInputs(resolvedInputs);
293
+ const touchesRemote = actionTouchesRemote(resolvedInputs.kind);
294
+ return {
295
+ schemaVersion: GIT_DELIVERY_ACTION_SHEET_SCHEMA_VERSION,
296
+ actionKind: resolvedInputs.kind,
297
+ riskClass,
298
+ riskSeverity: GIT_DELIVERY_RISK_CLASS_SEVERITY[riskClass],
299
+ ...previewBranchAndScopeFields(resolvedInputs, kernelPreview),
300
+ touchesRemote,
301
+ wouldCreateRemoteBranch: wouldCreateRemoteBranchOf(resolvedInputs, kernelPreview),
302
+ wouldForcePublish: wouldForcePublishOf(resolvedInputs),
303
+ // Re-derived from inputs (every remote action kind triggers checks), not read from
304
+ // kernelPreview.wouldTriggerChecks: the local kernel always reports false, and this projection
305
+ // owns the UI-facing derivation. The two are equivalent for the current action kinds.
306
+ wouldTriggerChecks: touchesRemote,
307
+ ...previewProviderFields(input),
308
+ expectedBlockers: input.expectedBlockers,
309
+ };
310
+ }
311
+ export function gitDeliveryApprovalNecessityForDecision(decision) {
312
+ switch (decision.outcome) {
313
+ case "approval-gated":
314
+ return "required";
315
+ case "blocked":
316
+ return decision.reason === "approval-expired" ? "required" : "impossible";
317
+ case "allowed":
318
+ case "constrained":
319
+ return "not-required";
320
+ default:
321
+ return "impossible";
322
+ }
323
+ }
324
+ function approvalIsAttached(approval) {
325
+ return approval.required;
326
+ }
327
+ function hasBlockingPreflight(blockers) {
328
+ return blockers.some((b) => b.source === "preflight" && b.severity === "blocking");
329
+ }
330
+ export function gitDeliveryActionSheetStateFor(input) {
331
+ if (!input.providerReady) {
332
+ return "blocked";
333
+ }
334
+ if (input.hasBlockingPreflight) {
335
+ return "blocked";
336
+ }
337
+ const decision = input.policyDecision;
338
+ if (decision.outcome === "blocked") {
339
+ return decision.reason === "approval-expired" ? "waiting-for-approval" : "blocked";
340
+ }
341
+ if (decision.outcome === "approval-gated") {
342
+ return approvalIsAttached(input.approvalRequirement)
343
+ ? "ready-to-execute"
344
+ : "waiting-for-approval";
345
+ }
346
+ return "ready-to-execute";
347
+ }
348
+ export function gitDeliveryBlockedCauseFor(input) {
349
+ if (!input.providerReady) {
350
+ return "provider-not-ready";
351
+ }
352
+ if (input.hasBlockingPreflight) {
353
+ return "preflight";
354
+ }
355
+ if (input.policyDecision.outcome === "blocked" &&
356
+ input.policyDecision.reason !== "approval-expired") {
357
+ return "policy";
358
+ }
359
+ return undefined;
360
+ }
361
+ // Fills the kernel's failure→suggested-strategy gap with a deterministic default: a dirty worktree
362
+ // must be preserved (stash), a commit is undone non-destructively (soft reset), everything else
363
+ // resets the index but keeps working-tree files (mixed reset).
364
+ export function gitDeliverySuggestedRecoveryStrategy(actionKind, worktreeIsDirty) {
365
+ if (worktreeIsDirty) {
366
+ return "stash-and-reset";
367
+ }
368
+ if (actionKind === "commit") {
369
+ return "soft-reset";
370
+ }
371
+ return "mixed-reset";
372
+ }
373
+ function buildApprovalSummary(resolvedInputs, decision, approval) {
374
+ const riskClass = gitDeliveryRiskClassForInputs(resolvedInputs);
375
+ const necessity = gitDeliveryApprovalNecessityForDecision(decision);
376
+ const requiredApprovers = decision.outcome === "approval-gated" ? decision.requiredApprovers : [];
377
+ return {
378
+ necessity,
379
+ satisfied: necessity === "required" && approvalIsAttached(approval),
380
+ riskClass,
381
+ riskSeverity: GIT_DELIVERY_RISK_CLASS_SEVERITY[riskClass],
382
+ requiredApprovers,
383
+ };
384
+ }
385
+ function buildPolicyExplanation(decision) {
386
+ const requiredApprovers = decision.outcome === "approval-gated" ? decision.requiredApprovers : [];
387
+ const constraints = decision.outcome === "constrained" ? decision.constraints : [];
388
+ const base = {
389
+ decision: decision.outcome,
390
+ requiredApprovers,
391
+ constraints,
392
+ };
393
+ if (decision.outcome === "blocked") {
394
+ return { ...base, blockReason: decision.reason };
395
+ }
396
+ return base;
397
+ }
398
+ export function buildGitDeliveryActionSheet(input) {
399
+ const stateInput = {
400
+ policyDecision: input.policyDecision,
401
+ approvalRequirement: input.approvalRequirement,
402
+ providerReady: input.providerReady,
403
+ hasBlockingPreflight: hasBlockingPreflight(input.expectedBlockers),
404
+ };
405
+ const state = gitDeliveryActionSheetStateFor(stateInput);
406
+ const preview = buildGitDeliveryPreviewManifest({
407
+ resolvedInputs: input.resolvedInputs,
408
+ expectedBlockers: input.expectedBlockers,
409
+ kernelPreview: input.kernelPreview,
410
+ pullRequest: input.pullRequest,
411
+ mergeReadiness: input.mergeReadiness,
412
+ branchProtection: input.branchProtection,
413
+ checks: input.checks,
414
+ });
415
+ const base = {
416
+ schemaVersion: GIT_DELIVERY_ACTION_SHEET_SCHEMA_VERSION,
417
+ actionId: input.actionId,
418
+ actionKind: input.resolvedInputs.kind,
419
+ state,
420
+ preview,
421
+ approval: buildApprovalSummary(input.resolvedInputs, input.policyDecision, input.approvalRequirement),
422
+ policyExplanation: buildPolicyExplanation(input.policyDecision),
423
+ recovery: input.recovery,
424
+ };
425
+ if (state !== "blocked") {
426
+ return base;
427
+ }
428
+ const cause = gitDeliveryBlockedCauseFor(stateInput) ?? "policy";
429
+ return { ...base, blocked: { cause, expectedBlockers: input.expectedBlockers } };
430
+ }
@@ -0,0 +1,92 @@
1
+ import type { GitDeliveryActionKind, GitDeliveryBlockReason, GitDeliveryExecutionErrorCode, GitDeliveryExecutionOutcome, GitDeliveryEvidenceRef, GitDeliveryPolicyDecision, GitDeliveryRecoveryStrategyHint, GitDeliveryRiskClass } from "./git-delivery.js";
2
+ import type { GitDeliveryRecoveryActionHint } from "./git-delivery-action-sheet.js";
3
+ export declare const GIT_DELIVERY_EVIDENCE_SCHEMA_VERSION: "1";
4
+ export type GitDeliveryEvidenceOutcomeClass = "succeeded" | "blocked" | "rejected" | "failed" | "recovery-required" | "approval-required";
5
+ export declare const GIT_DELIVERY_EVIDENCE_OUTCOME_CLASSES: readonly GitDeliveryEvidenceOutcomeClass[];
6
+ export type GitDeliveryRecoveryDisposition = "retryable" | "user-fixable" | "policy-forbidden" | "none";
7
+ export declare const GIT_DELIVERY_RECOVERY_DISPOSITIONS: readonly GitDeliveryRecoveryDisposition[];
8
+ export type GitDeliveryEvidenceLifecyclePhase = "resolve" | "preflight" | "preview" | "policy" | "execute" | "result";
9
+ export declare const GIT_DELIVERY_EVIDENCE_LIFECYCLE_PHASES: readonly GitDeliveryEvidenceLifecyclePhase[];
10
+ export interface GitDeliveryRecoveryMetadata {
11
+ readonly disposition: GitDeliveryRecoveryDisposition;
12
+ readonly actionHint?: GitDeliveryRecoveryActionHint | undefined;
13
+ readonly executionErrorCode?: GitDeliveryExecutionErrorCode | undefined;
14
+ readonly blockReason?: GitDeliveryBlockReason | undefined;
15
+ readonly suggestedRecoveryStrategy?: GitDeliveryRecoveryStrategyHint | undefined;
16
+ }
17
+ export interface GitDeliveryEvidenceCorrelation {
18
+ readonly workflowRunIdHash: string;
19
+ readonly actionId: string;
20
+ readonly attemptSequence?: number | undefined;
21
+ }
22
+ export interface GitDeliveryEvidenceApproval {
23
+ readonly required: boolean;
24
+ readonly approvalTokenHash?: string | undefined;
25
+ readonly approvedByUserId?: string | undefined;
26
+ readonly approvedAtMs?: number | undefined;
27
+ readonly expiresAtMs?: number | undefined;
28
+ }
29
+ export interface GitDeliveryEvidencePreviewSummary {
30
+ readonly affectedBranchName?: string | undefined;
31
+ readonly estimatedFileCount?: number | undefined;
32
+ readonly estimatedBytesDelta?: number | undefined;
33
+ readonly wouldCreateRemoteBranch: boolean;
34
+ readonly wouldTriggerChecks: boolean;
35
+ }
36
+ export interface GitDeliveryEvidenceExecution {
37
+ readonly outcome: GitDeliveryExecutionOutcome;
38
+ readonly durationMs: number;
39
+ readonly errorCode?: GitDeliveryExecutionErrorCode | undefined;
40
+ readonly attemptedUnitCount?: number | undefined;
41
+ readonly succeededUnitCount?: number | undefined;
42
+ readonly externalIdHash?: string | undefined;
43
+ }
44
+ export interface GitDeliveryEvidenceRepoContext {
45
+ readonly repoIdHash?: string | undefined;
46
+ readonly targetBranchName?: string | undefined;
47
+ readonly headDetached?: boolean | undefined;
48
+ readonly stagedFileCount?: number | undefined;
49
+ readonly unstagedFileCount?: number | undefined;
50
+ readonly untrackedFileCount?: number | undefined;
51
+ readonly remoteRefHash?: string | undefined;
52
+ }
53
+ export interface GitDeliveryEvidenceRecord {
54
+ readonly schemaVersion: typeof GIT_DELIVERY_EVIDENCE_SCHEMA_VERSION;
55
+ readonly evidenceId: string;
56
+ readonly actionKind: GitDeliveryActionKind;
57
+ readonly riskClass: GitDeliveryRiskClass;
58
+ readonly riskSeverity: number;
59
+ readonly outcomeClass: GitDeliveryEvidenceOutcomeClass;
60
+ readonly phaseReached: GitDeliveryEvidenceLifecyclePhase;
61
+ readonly policyOutcome: GitDeliveryPolicyDecision["outcome"];
62
+ readonly blockReason?: GitDeliveryBlockReason | undefined;
63
+ readonly requiredApprovers?: readonly string[] | undefined;
64
+ readonly correlation: GitDeliveryEvidenceCorrelation;
65
+ readonly approval: GitDeliveryEvidenceApproval;
66
+ readonly preview?: GitDeliveryEvidencePreviewSummary | undefined;
67
+ readonly execution?: GitDeliveryEvidenceExecution | undefined;
68
+ readonly repoContext: GitDeliveryEvidenceRepoContext;
69
+ readonly recovery: GitDeliveryRecoveryMetadata;
70
+ readonly recordedAtMs: number;
71
+ readonly evidenceRef?: GitDeliveryEvidenceRef | undefined;
72
+ }
73
+ export interface GitDeliveryAuditPacket {
74
+ readonly schemaVersion: typeof GIT_DELIVERY_EVIDENCE_SCHEMA_VERSION;
75
+ readonly generatedAtMs: number;
76
+ readonly recordCount: number;
77
+ readonly records: readonly GitDeliveryEvidenceRecord[];
78
+ readonly outcomeClassCounts: Readonly<Record<GitDeliveryEvidenceOutcomeClass, number>>;
79
+ readonly recoveryDispositionCounts: Readonly<Record<GitDeliveryRecoveryDisposition, number>>;
80
+ readonly knownLimitations: readonly string[];
81
+ }
82
+ export declare function gitDeliveryRecoveryDispositionForExecutionError(code: GitDeliveryExecutionErrorCode): GitDeliveryRecoveryDisposition;
83
+ export declare function gitDeliveryRecoveryDispositionForBlockReason(reason: GitDeliveryBlockReason): GitDeliveryRecoveryDisposition;
84
+ export declare const GIT_DELIVERY_AUDIT_PACKET_KNOWN_LIMITATIONS: readonly string[];
85
+ export declare function buildGitDeliveryAuditPacket(records: readonly GitDeliveryEvidenceRecord[], generatedAtMs: number, extraLimitations?: readonly string[]): GitDeliveryAuditPacket;
86
+ export declare const isGitDeliveryEvidenceOutcomeClass: (v: unknown) => v is GitDeliveryEvidenceOutcomeClass;
87
+ export declare const isGitDeliveryRecoveryDisposition: (v: unknown) => v is GitDeliveryRecoveryDisposition;
88
+ export declare const isGitDeliveryEvidenceLifecyclePhase: (v: unknown) => v is GitDeliveryEvidenceLifecyclePhase;
89
+ export declare function isGitDeliveryRecoveryMetadata(value: unknown): value is GitDeliveryRecoveryMetadata;
90
+ export declare function isGitDeliveryEvidenceRecord(value: unknown): value is GitDeliveryEvidenceRecord;
91
+ export declare function isGitDeliveryAuditPacket(value: unknown): value is GitDeliveryAuditPacket;
92
+ //# sourceMappingURL=git-delivery-evidence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-delivery-evidence.d.ts","sourceRoot":"","sources":["../src/git-delivery-evidence.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACtB,6BAA6B,EAC7B,2BAA2B,EAC3B,sBAAsB,EACtB,yBAAyB,EACzB,+BAA+B,EAC/B,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAU3B,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAIpF,eAAO,MAAM,oCAAoC,EAAG,GAAY,CAAC;AAQjE,MAAM,MAAM,+BAA+B,GACvC,WAAW,GACX,SAAS,GACT,UAAU,GACV,QAAQ,GACR,mBAAmB,GACnB,mBAAmB,CAAC;AAExB,eAAO,MAAM,qCAAqC,EAAE,SAAS,+BAA+B,EAOlF,CAAC;AAUX,MAAM,MAAM,8BAA8B,GACtC,WAAW,GACX,cAAc,GACd,kBAAkB,GAClB,MAAM,CAAC;AAEX,eAAO,MAAM,kCAAkC,EAAE,SAAS,8BAA8B,EAK9E,CAAC;AAQX,MAAM,MAAM,iCAAiC,GACzC,SAAS,GACT,WAAW,GACX,SAAS,GACT,QAAQ,GACR,SAAS,GACT,QAAQ,CAAC;AAEb,eAAO,MAAM,sCAAsC,EAAE,SAAS,iCAAiC,EAClB,CAAC;AAO9E,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,WAAW,EAAE,8BAA8B,CAAC;IAGrD,QAAQ,CAAC,UAAU,CAAC,EAAE,6BAA6B,GAAG,SAA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