@riddledc/riddle-proof 0.4.2 → 0.4.4

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/dist/runner.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  runRiddleProof
3
- } from "./chunk-CL2FOOXX.js";
4
- import "./chunk-3XJJ4JOB.js";
5
- import "./chunk-5DC6YXN4.js";
3
+ } from "./chunk-PM5Q26Q6.js";
4
+ import "./chunk-SIQG3N6F.js";
5
+ import "./chunk-TMMKRKY5.js";
6
6
  export {
7
7
  runRiddleProof
8
8
  };
package/dist/state.cjs CHANGED
@@ -23,9 +23,11 @@ __export(state_exports, {
23
23
  RIDDLE_PROOF_RUN_STATE_VERSION: () => RIDDLE_PROOF_RUN_STATE_VERSION,
24
24
  appendRunEvent: () => appendRunEvent,
25
25
  appendStageHeartbeat: () => appendStageHeartbeat,
26
+ applyPrLifecycleState: () => applyPrLifecycleState,
26
27
  createRunState: () => createRunState,
27
28
  createRunStatusSnapshot: () => createRunStatusSnapshot,
28
29
  normalizeIntegrationContext: () => normalizeIntegrationContext,
30
+ normalizePrLifecycleState: () => normalizePrLifecycleState,
29
31
  normalizeRunParams: () => normalizeRunParams,
30
32
  setRunStatus: () => setRunStatus
31
33
  });
@@ -58,6 +60,36 @@ function elapsedMs(start, end) {
58
60
  if (!Number.isFinite(startMs) || !Number.isFinite(endMs)) return void 0;
59
61
  return Math.max(0, endMs - startMs);
60
62
  }
63
+ function normalizePrStatus(value) {
64
+ const status = nonEmptyString(value)?.toLowerCase();
65
+ if (status === "merged") return "merged";
66
+ if (status === "open") return "open";
67
+ if (status === "closed") return "closed";
68
+ if (status === "not_found" || status === "not-found") return "not_found";
69
+ if (status === "unavailable") return "unavailable";
70
+ return status || "unknown";
71
+ }
72
+ function normalizePrLifecycleState(input, checkedAt = timestamp()) {
73
+ const value = recordValue(input);
74
+ if (!value) return void 0;
75
+ const cleanup = recordValue(value.cleanup);
76
+ const mergeCommit = nonEmptyString(value.merge_commit) || nonEmptyString(value.mergeCommit) || nonEmptyString(recordValue(value.mergeCommit)?.oid);
77
+ return compactRecord({
78
+ status: normalizePrStatus(value.status || value.state),
79
+ pr_url: nonEmptyString(value.pr_url) || nonEmptyString(value.prUrl) || nonEmptyString(value.url),
80
+ pr_number: nonEmptyString(value.pr_number) || nonEmptyString(value.prNumber) || (typeof value.number === "number" ? String(value.number) : void 0),
81
+ repo: nonEmptyString(value.repo) || nonEmptyString(value.repository),
82
+ head_branch: nonEmptyString(value.head_branch) || nonEmptyString(value.headBranch) || nonEmptyString(value.headRefName),
83
+ base_branch: nonEmptyString(value.base_branch) || nonEmptyString(value.baseBranch) || nonEmptyString(value.baseRefName),
84
+ merge_commit: mergeCommit,
85
+ merged_at: nonEmptyString(value.merged_at) || nonEmptyString(value.mergedAt),
86
+ closed_at: nonEmptyString(value.closed_at) || nonEmptyString(value.closedAt),
87
+ checked_at: nonEmptyString(value.checked_at) || nonEmptyString(value.checkedAt) || checkedAt,
88
+ source: nonEmptyString(value.source),
89
+ next_action: nonEmptyString(value.next_action) || nonEmptyString(value.nextAction),
90
+ cleanup: cleanup && Object.keys(cleanup).length ? cleanup : void 0
91
+ });
92
+ }
61
93
  function normalizeIntegrationContext(input, fallbackSource) {
62
94
  const value = recordValue(input);
63
95
  if (!value) {
@@ -181,6 +213,16 @@ function createRunStatusSnapshot(state, at = timestamp()) {
181
213
  state_path: state.state_path ?? null,
182
214
  worktree_path: state.worktree_path ?? null,
183
215
  branch: state.branch ?? null,
216
+ pr_url: state.pr_url ?? null,
217
+ pr_branch: state.pr_branch ?? null,
218
+ pr_state: state.pr_state,
219
+ ci_status: state.ci_status,
220
+ ship_commit: state.ship_commit,
221
+ ship_remote_head: state.ship_remote_head,
222
+ merge_commit: state.merge_commit,
223
+ merged_at: state.merged_at,
224
+ proof_comment_url: state.proof_comment_url,
225
+ cleanup_report: state.cleanup_report,
184
226
  iterations: state.iterations,
185
227
  last_checkpoint: state.last_checkpoint ?? null,
186
228
  updated_at: state.updated_at,
@@ -196,14 +238,33 @@ function setRunStatus(state, status, at = timestamp()) {
196
238
  state.updated_at = at;
197
239
  return state;
198
240
  }
241
+ function applyPrLifecycleState(state, input, at = timestamp()) {
242
+ const prState = normalizePrLifecycleState(input, at);
243
+ if (!prState) return state;
244
+ state.pr_state = prState;
245
+ if (prState.pr_url) state.pr_url = prState.pr_url;
246
+ if (prState.head_branch) state.pr_branch = prState.head_branch;
247
+ if (prState.merge_commit) state.merge_commit = prState.merge_commit;
248
+ if (prState.merged_at) state.merged_at = prState.merged_at;
249
+ if (prState.cleanup) state.cleanup_report = prState.cleanup;
250
+ if (prState.status === "merged") {
251
+ state.finalized = true;
252
+ state.status = "completed";
253
+ state.ok = true;
254
+ }
255
+ state.updated_at = at;
256
+ return state;
257
+ }
199
258
  // Annotate the CommonJS export names for ESM import in node:
200
259
  0 && (module.exports = {
201
260
  RIDDLE_PROOF_RUN_STATE_VERSION,
202
261
  appendRunEvent,
203
262
  appendStageHeartbeat,
263
+ applyPrLifecycleState,
204
264
  createRunState,
205
265
  createRunStatusSnapshot,
206
266
  normalizeIntegrationContext,
267
+ normalizePrLifecycleState,
207
268
  normalizeRunParams,
208
269
  setRunStatus
209
270
  });
package/dist/state.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { RiddleProofRunParams, RiddleProofStatus, RiddleProofStage, RiddleProofEvent, RiddleProofRunState, RiddleProofRunStatusSnapshot, IntegrationContext } from './types.cjs';
1
+ import { RiddleProofRunParams, RiddleProofStatus, RiddleProofStage, RiddleProofEvent, RiddleProofRunState, RiddleProofPrLifecycleState, RiddleProofRunStatusSnapshot, IntegrationContext } from './types.cjs';
2
2
 
3
3
  declare const RIDDLE_PROOF_RUN_STATE_VERSION: "riddle-proof.run-state.v1";
4
4
  interface CreateRunStateInput {
@@ -19,6 +19,7 @@ interface CreateRunStateInput {
19
19
  type RunEventInput = Omit<RiddleProofEvent, "ts"> & {
20
20
  ts?: string;
21
21
  };
22
+ declare function normalizePrLifecycleState(input?: Partial<RiddleProofPrLifecycleState> | Record<string, unknown> | null, checkedAt?: string): RiddleProofPrLifecycleState | undefined;
22
23
  declare function normalizeIntegrationContext(input?: Partial<IntegrationContext> | Record<string, unknown> | null, fallbackSource?: IntegrationContext["source"]): IntegrationContext | undefined;
23
24
  declare function normalizeRunParams(input: RiddleProofRunParams): RiddleProofRunParams;
24
25
  declare function createRunState(input: CreateRunStateInput): RiddleProofRunState;
@@ -34,5 +35,6 @@ declare function appendStageHeartbeat<T extends RiddleProofRunState>(state: T, i
34
35
  }): T;
35
36
  declare function createRunStatusSnapshot(state: RiddleProofRunState, at?: string): RiddleProofRunStatusSnapshot;
36
37
  declare function setRunStatus<T extends RiddleProofRunState>(state: T, status: RiddleProofStatus, at?: string): T;
38
+ declare function applyPrLifecycleState<T extends RiddleProofRunState>(state: T, input?: Partial<RiddleProofPrLifecycleState> | Record<string, unknown> | null, at?: string): T;
37
39
 
38
- export { type CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, type RunEventInput, appendRunEvent, appendStageHeartbeat, createRunState, createRunStatusSnapshot, normalizeIntegrationContext, normalizeRunParams, setRunStatus };
40
+ export { type CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, type RunEventInput, appendRunEvent, appendStageHeartbeat, applyPrLifecycleState, createRunState, createRunStatusSnapshot, normalizeIntegrationContext, normalizePrLifecycleState, normalizeRunParams, setRunStatus };
package/dist/state.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { RiddleProofRunParams, RiddleProofStatus, RiddleProofStage, RiddleProofEvent, RiddleProofRunState, RiddleProofRunStatusSnapshot, IntegrationContext } from './types.js';
1
+ import { RiddleProofRunParams, RiddleProofStatus, RiddleProofStage, RiddleProofEvent, RiddleProofRunState, RiddleProofPrLifecycleState, RiddleProofRunStatusSnapshot, IntegrationContext } from './types.js';
2
2
 
3
3
  declare const RIDDLE_PROOF_RUN_STATE_VERSION: "riddle-proof.run-state.v1";
4
4
  interface CreateRunStateInput {
@@ -19,6 +19,7 @@ interface CreateRunStateInput {
19
19
  type RunEventInput = Omit<RiddleProofEvent, "ts"> & {
20
20
  ts?: string;
21
21
  };
22
+ declare function normalizePrLifecycleState(input?: Partial<RiddleProofPrLifecycleState> | Record<string, unknown> | null, checkedAt?: string): RiddleProofPrLifecycleState | undefined;
22
23
  declare function normalizeIntegrationContext(input?: Partial<IntegrationContext> | Record<string, unknown> | null, fallbackSource?: IntegrationContext["source"]): IntegrationContext | undefined;
23
24
  declare function normalizeRunParams(input: RiddleProofRunParams): RiddleProofRunParams;
24
25
  declare function createRunState(input: CreateRunStateInput): RiddleProofRunState;
@@ -34,5 +35,6 @@ declare function appendStageHeartbeat<T extends RiddleProofRunState>(state: T, i
34
35
  }): T;
35
36
  declare function createRunStatusSnapshot(state: RiddleProofRunState, at?: string): RiddleProofRunStatusSnapshot;
36
37
  declare function setRunStatus<T extends RiddleProofRunState>(state: T, status: RiddleProofStatus, at?: string): T;
38
+ declare function applyPrLifecycleState<T extends RiddleProofRunState>(state: T, input?: Partial<RiddleProofPrLifecycleState> | Record<string, unknown> | null, at?: string): T;
37
39
 
38
- export { type CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, type RunEventInput, appendRunEvent, appendStageHeartbeat, createRunState, createRunStatusSnapshot, normalizeIntegrationContext, normalizeRunParams, setRunStatus };
40
+ export { type CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, type RunEventInput, appendRunEvent, appendStageHeartbeat, applyPrLifecycleState, createRunState, createRunStatusSnapshot, normalizeIntegrationContext, normalizePrLifecycleState, normalizeRunParams, setRunStatus };
package/dist/state.js CHANGED
@@ -2,20 +2,24 @@ import {
2
2
  RIDDLE_PROOF_RUN_STATE_VERSION,
3
3
  appendRunEvent,
4
4
  appendStageHeartbeat,
5
+ applyPrLifecycleState,
5
6
  createRunState,
6
7
  createRunStatusSnapshot,
7
8
  normalizeIntegrationContext,
9
+ normalizePrLifecycleState,
8
10
  normalizeRunParams,
9
11
  setRunStatus
10
- } from "./chunk-3XJJ4JOB.js";
11
- import "./chunk-5DC6YXN4.js";
12
+ } from "./chunk-SIQG3N6F.js";
13
+ import "./chunk-TMMKRKY5.js";
12
14
  export {
13
15
  RIDDLE_PROOF_RUN_STATE_VERSION,
14
16
  appendRunEvent,
15
17
  appendStageHeartbeat,
18
+ applyPrLifecycleState,
16
19
  createRunState,
17
20
  createRunStatusSnapshot,
18
21
  normalizeIntegrationContext,
22
+ normalizePrLifecycleState,
19
23
  normalizeRunParams,
20
24
  setRunStatus
21
25
  };
package/dist/types.d.cts CHANGED
@@ -4,6 +4,7 @@ type JsonObject = {
4
4
  [key: string]: JsonValue;
5
5
  };
6
6
  type RiddleProofStatus = "running" | "blocked" | "failed" | "ready_to_ship" | "shipped" | "completed";
7
+ type RiddleProofPrLifecycleStatus = "unknown" | "open" | "merged" | "closed" | "not_found" | "unavailable" | (string & {});
7
8
  type RiddleProofVerificationMode = "proof" | "visual" | "interaction" | "render" | "data" | "json" | "audio" | "log" | "logs" | "metric" | "metrics" | (string & {});
8
9
  type RiddleProofDecision = "ready_to_ship" | "needs_richer_proof" | "revise_capture" | "needs_recon" | "needs_implementation" | (string & {});
9
10
  type RiddleProofStage = "preflight" | "setup" | "recon" | "author" | "implement" | "prove" | "verify" | "ship" | "notify" | (string & {});
@@ -81,7 +82,21 @@ interface RiddleProofRunState {
81
82
  iterations: number;
82
83
  last_checkpoint?: string | null;
83
84
  pr_url?: string;
85
+ pr_branch?: string;
86
+ pr_state?: RiddleProofPrLifecycleState;
84
87
  marked_ready?: boolean;
88
+ left_draft?: boolean;
89
+ ci_status?: string;
90
+ ship_commit?: string;
91
+ ship_remote_head?: string;
92
+ merge_commit?: string;
93
+ merged_at?: string;
94
+ proof_comment_url?: string;
95
+ before_artifact_url?: string;
96
+ prod_artifact_url?: string;
97
+ after_artifact_url?: string;
98
+ ship_report?: Record<string, unknown>;
99
+ cleanup_report?: Record<string, unknown>;
85
100
  notification?: Record<string, unknown>;
86
101
  proof_decision?: RiddleProofDecision;
87
102
  merge_recommendation?: string;
@@ -102,7 +117,21 @@ interface RiddleProofRunResult {
102
117
  last_summary?: string | null;
103
118
  event_count?: number;
104
119
  pr_url?: string;
120
+ pr_branch?: string;
121
+ pr_state?: RiddleProofPrLifecycleState;
105
122
  marked_ready?: boolean;
123
+ left_draft?: boolean;
124
+ ci_status?: string;
125
+ ship_commit?: string;
126
+ ship_remote_head?: string;
127
+ merge_commit?: string;
128
+ merged_at?: string;
129
+ proof_comment_url?: string;
130
+ before_artifact_url?: string;
131
+ prod_artifact_url?: string;
132
+ after_artifact_url?: string;
133
+ ship_report?: Record<string, unknown>;
134
+ cleanup_report?: Record<string, unknown>;
106
135
  notification?: Record<string, unknown>;
107
136
  proof_decision?: RiddleProofDecision;
108
137
  merge_recommendation?: string;
@@ -118,6 +147,16 @@ interface RiddleProofRunStatusSnapshot {
118
147
  state_path?: string | null;
119
148
  worktree_path?: string | null;
120
149
  branch?: string | null;
150
+ pr_url?: string | null;
151
+ pr_branch?: string | null;
152
+ pr_state?: RiddleProofPrLifecycleState;
153
+ ci_status?: string;
154
+ ship_commit?: string;
155
+ ship_remote_head?: string;
156
+ merge_commit?: string;
157
+ merged_at?: string;
158
+ proof_comment_url?: string;
159
+ cleanup_report?: Record<string, unknown>;
121
160
  iterations: number;
122
161
  last_checkpoint?: string | null;
123
162
  updated_at: string;
@@ -134,6 +173,7 @@ interface RiddleProofEvidenceBundle {
134
173
  proof_evidence?: unknown;
135
174
  proof_evidence_sample?: unknown;
136
175
  assertions?: JsonValue;
176
+ semantic_context?: Record<string, unknown>;
137
177
  summary?: string;
138
178
  notes?: string[];
139
179
  }
@@ -247,11 +287,40 @@ interface NotificationAdapter {
247
287
  }
248
288
  interface RiddleProofTerminalMetadata {
249
289
  pr_url?: string;
290
+ pr_branch?: string;
291
+ pr_state?: RiddleProofPrLifecycleState;
250
292
  marked_ready?: boolean;
293
+ left_draft?: boolean;
294
+ ci_status?: string;
295
+ ship_commit?: string;
296
+ ship_remote_head?: string;
297
+ merge_commit?: string;
298
+ merged_at?: string;
299
+ proof_comment_url?: string;
300
+ before_artifact_url?: string;
301
+ prod_artifact_url?: string;
302
+ after_artifact_url?: string;
303
+ ship_report?: Record<string, unknown>;
304
+ cleanup_report?: Record<string, unknown>;
251
305
  notification?: Record<string, unknown>;
252
306
  proof_decision?: RiddleProofDecision;
253
307
  merge_recommendation?: string;
254
308
  finalized?: boolean;
255
309
  }
310
+ interface RiddleProofPrLifecycleState {
311
+ status: RiddleProofPrLifecycleStatus;
312
+ pr_url?: string;
313
+ pr_number?: string;
314
+ repo?: string;
315
+ head_branch?: string;
316
+ base_branch?: string;
317
+ merge_commit?: string;
318
+ merged_at?: string;
319
+ closed_at?: string;
320
+ checked_at?: string;
321
+ source?: string;
322
+ next_action?: string;
323
+ cleanup?: Record<string, unknown>;
324
+ }
256
325
 
257
- export type { EvidenceArtifact, EvidenceReference, ImplementationAdapter, ImplementationAdapterInput, ImplementationAdapterResult, IntegrationContext, JsonObject, JsonPrimitive, JsonValue, JudgeAdapter, NotificationAdapter, PreflightAdapter, PreflightAdapterInput, PreflightAdapterResult, ProofAdapter, ProofAdapterInput, ProofAdapterResult, RiddleProofArtifactRole, RiddleProofAssessment, RiddleProofBlocker, RiddleProofDecision, RiddleProofEvent, RiddleProofEvidenceBundle, RiddleProofRunParams, RiddleProofRunResult, RiddleProofRunState, RiddleProofRunStatusSnapshot, RiddleProofStage, RiddleProofStatus, RiddleProofTerminalMetadata, RiddleProofVerificationMode, SetupAdapter, SetupAdapterInput, SetupAdapterResult, ShipAdapter };
326
+ export type { EvidenceArtifact, EvidenceReference, ImplementationAdapter, ImplementationAdapterInput, ImplementationAdapterResult, IntegrationContext, JsonObject, JsonPrimitive, JsonValue, JudgeAdapter, NotificationAdapter, PreflightAdapter, PreflightAdapterInput, PreflightAdapterResult, ProofAdapter, ProofAdapterInput, ProofAdapterResult, RiddleProofArtifactRole, RiddleProofAssessment, RiddleProofBlocker, RiddleProofDecision, RiddleProofEvent, RiddleProofEvidenceBundle, RiddleProofPrLifecycleState, RiddleProofPrLifecycleStatus, RiddleProofRunParams, RiddleProofRunResult, RiddleProofRunState, RiddleProofRunStatusSnapshot, RiddleProofStage, RiddleProofStatus, RiddleProofTerminalMetadata, RiddleProofVerificationMode, SetupAdapter, SetupAdapterInput, SetupAdapterResult, ShipAdapter };
package/dist/types.d.ts CHANGED
@@ -4,6 +4,7 @@ type JsonObject = {
4
4
  [key: string]: JsonValue;
5
5
  };
6
6
  type RiddleProofStatus = "running" | "blocked" | "failed" | "ready_to_ship" | "shipped" | "completed";
7
+ type RiddleProofPrLifecycleStatus = "unknown" | "open" | "merged" | "closed" | "not_found" | "unavailable" | (string & {});
7
8
  type RiddleProofVerificationMode = "proof" | "visual" | "interaction" | "render" | "data" | "json" | "audio" | "log" | "logs" | "metric" | "metrics" | (string & {});
8
9
  type RiddleProofDecision = "ready_to_ship" | "needs_richer_proof" | "revise_capture" | "needs_recon" | "needs_implementation" | (string & {});
9
10
  type RiddleProofStage = "preflight" | "setup" | "recon" | "author" | "implement" | "prove" | "verify" | "ship" | "notify" | (string & {});
@@ -81,7 +82,21 @@ interface RiddleProofRunState {
81
82
  iterations: number;
82
83
  last_checkpoint?: string | null;
83
84
  pr_url?: string;
85
+ pr_branch?: string;
86
+ pr_state?: RiddleProofPrLifecycleState;
84
87
  marked_ready?: boolean;
88
+ left_draft?: boolean;
89
+ ci_status?: string;
90
+ ship_commit?: string;
91
+ ship_remote_head?: string;
92
+ merge_commit?: string;
93
+ merged_at?: string;
94
+ proof_comment_url?: string;
95
+ before_artifact_url?: string;
96
+ prod_artifact_url?: string;
97
+ after_artifact_url?: string;
98
+ ship_report?: Record<string, unknown>;
99
+ cleanup_report?: Record<string, unknown>;
85
100
  notification?: Record<string, unknown>;
86
101
  proof_decision?: RiddleProofDecision;
87
102
  merge_recommendation?: string;
@@ -102,7 +117,21 @@ interface RiddleProofRunResult {
102
117
  last_summary?: string | null;
103
118
  event_count?: number;
104
119
  pr_url?: string;
120
+ pr_branch?: string;
121
+ pr_state?: RiddleProofPrLifecycleState;
105
122
  marked_ready?: boolean;
123
+ left_draft?: boolean;
124
+ ci_status?: string;
125
+ ship_commit?: string;
126
+ ship_remote_head?: string;
127
+ merge_commit?: string;
128
+ merged_at?: string;
129
+ proof_comment_url?: string;
130
+ before_artifact_url?: string;
131
+ prod_artifact_url?: string;
132
+ after_artifact_url?: string;
133
+ ship_report?: Record<string, unknown>;
134
+ cleanup_report?: Record<string, unknown>;
106
135
  notification?: Record<string, unknown>;
107
136
  proof_decision?: RiddleProofDecision;
108
137
  merge_recommendation?: string;
@@ -118,6 +147,16 @@ interface RiddleProofRunStatusSnapshot {
118
147
  state_path?: string | null;
119
148
  worktree_path?: string | null;
120
149
  branch?: string | null;
150
+ pr_url?: string | null;
151
+ pr_branch?: string | null;
152
+ pr_state?: RiddleProofPrLifecycleState;
153
+ ci_status?: string;
154
+ ship_commit?: string;
155
+ ship_remote_head?: string;
156
+ merge_commit?: string;
157
+ merged_at?: string;
158
+ proof_comment_url?: string;
159
+ cleanup_report?: Record<string, unknown>;
121
160
  iterations: number;
122
161
  last_checkpoint?: string | null;
123
162
  updated_at: string;
@@ -134,6 +173,7 @@ interface RiddleProofEvidenceBundle {
134
173
  proof_evidence?: unknown;
135
174
  proof_evidence_sample?: unknown;
136
175
  assertions?: JsonValue;
176
+ semantic_context?: Record<string, unknown>;
137
177
  summary?: string;
138
178
  notes?: string[];
139
179
  }
@@ -247,11 +287,40 @@ interface NotificationAdapter {
247
287
  }
248
288
  interface RiddleProofTerminalMetadata {
249
289
  pr_url?: string;
290
+ pr_branch?: string;
291
+ pr_state?: RiddleProofPrLifecycleState;
250
292
  marked_ready?: boolean;
293
+ left_draft?: boolean;
294
+ ci_status?: string;
295
+ ship_commit?: string;
296
+ ship_remote_head?: string;
297
+ merge_commit?: string;
298
+ merged_at?: string;
299
+ proof_comment_url?: string;
300
+ before_artifact_url?: string;
301
+ prod_artifact_url?: string;
302
+ after_artifact_url?: string;
303
+ ship_report?: Record<string, unknown>;
304
+ cleanup_report?: Record<string, unknown>;
251
305
  notification?: Record<string, unknown>;
252
306
  proof_decision?: RiddleProofDecision;
253
307
  merge_recommendation?: string;
254
308
  finalized?: boolean;
255
309
  }
310
+ interface RiddleProofPrLifecycleState {
311
+ status: RiddleProofPrLifecycleStatus;
312
+ pr_url?: string;
313
+ pr_number?: string;
314
+ repo?: string;
315
+ head_branch?: string;
316
+ base_branch?: string;
317
+ merge_commit?: string;
318
+ merged_at?: string;
319
+ closed_at?: string;
320
+ checked_at?: string;
321
+ source?: string;
322
+ next_action?: string;
323
+ cleanup?: Record<string, unknown>;
324
+ }
256
325
 
257
- export type { EvidenceArtifact, EvidenceReference, ImplementationAdapter, ImplementationAdapterInput, ImplementationAdapterResult, IntegrationContext, JsonObject, JsonPrimitive, JsonValue, JudgeAdapter, NotificationAdapter, PreflightAdapter, PreflightAdapterInput, PreflightAdapterResult, ProofAdapter, ProofAdapterInput, ProofAdapterResult, RiddleProofArtifactRole, RiddleProofAssessment, RiddleProofBlocker, RiddleProofDecision, RiddleProofEvent, RiddleProofEvidenceBundle, RiddleProofRunParams, RiddleProofRunResult, RiddleProofRunState, RiddleProofRunStatusSnapshot, RiddleProofStage, RiddleProofStatus, RiddleProofTerminalMetadata, RiddleProofVerificationMode, SetupAdapter, SetupAdapterInput, SetupAdapterResult, ShipAdapter };
326
+ export type { EvidenceArtifact, EvidenceReference, ImplementationAdapter, ImplementationAdapterInput, ImplementationAdapterResult, IntegrationContext, JsonObject, JsonPrimitive, JsonValue, JudgeAdapter, NotificationAdapter, PreflightAdapter, PreflightAdapterInput, PreflightAdapterResult, ProofAdapter, ProofAdapterInput, ProofAdapterResult, RiddleProofArtifactRole, RiddleProofAssessment, RiddleProofBlocker, RiddleProofDecision, RiddleProofEvent, RiddleProofEvidenceBundle, RiddleProofPrLifecycleState, RiddleProofPrLifecycleStatus, RiddleProofRunParams, RiddleProofRunResult, RiddleProofRunState, RiddleProofRunStatusSnapshot, RiddleProofStage, RiddleProofStatus, RiddleProofTerminalMetadata, RiddleProofVerificationMode, SetupAdapter, SetupAdapterInput, SetupAdapterResult, ShipAdapter };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",
@@ -1,85 +0,0 @@
1
- // src/result.ts
2
- function isTerminalStatus(status) {
3
- return status === "blocked" || status === "failed" || status === "ready_to_ship" || status === "shipped" || status === "completed";
4
- }
5
- function isSuccessfulStatus(status) {
6
- return status !== "blocked" && status !== "failed";
7
- }
8
- function compactRecord(input) {
9
- return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0 && value !== null && value !== ""));
10
- }
11
- function nonEmptyString(value) {
12
- return typeof value === "string" && value.trim() ? value.trim() : void 0;
13
- }
14
- function recordValue(value) {
15
- return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
16
- }
17
- function normalizeTerminalMetadata(input) {
18
- const riddleState = recordValue(input.riddleState) || {};
19
- const result = recordValue(input.engineResult) || {};
20
- const contract = recordValue(result.checkpointContract) || {};
21
- const details = recordValue(input.checkpointDetails) || recordValue(contract.details) || {};
22
- const markedReady = riddleState.marked_ready ?? result.marked_ready ?? result.markedReady ?? details.marked_ready ?? details.markedReady;
23
- const finalized = riddleState.finalized ?? result.finalized ?? details.finalized;
24
- return compactRecord({
25
- pr_url: nonEmptyString(riddleState.pr_url) || nonEmptyString(result.pr_url) || nonEmptyString(result.prUrl) || nonEmptyString(details.pr_url) || nonEmptyString(details.prUrl),
26
- marked_ready: typeof markedReady === "boolean" ? markedReady : void 0,
27
- notification: recordValue(riddleState.notification) || recordValue(riddleState.discord_notification) || recordValue(result.notification) || recordValue(result.discord_notification),
28
- proof_decision: nonEmptyString(riddleState.proof_decision) || nonEmptyString(result.proof_decision),
29
- merge_recommendation: nonEmptyString(riddleState.merge_recommendation) || nonEmptyString(result.merge_recommendation),
30
- finalized: typeof finalized === "boolean" ? finalized : void 0
31
- });
32
- }
33
- function applyTerminalMetadata(state, metadata) {
34
- const prUrl = nonEmptyString(metadata.pr_url);
35
- if (prUrl) state.pr_url = prUrl;
36
- if (typeof metadata.marked_ready === "boolean") state.marked_ready = metadata.marked_ready;
37
- const notification = recordValue(metadata.notification);
38
- if (notification) state.notification = notification;
39
- const proofDecision = nonEmptyString(metadata.proof_decision);
40
- if (proofDecision) state.proof_decision = proofDecision;
41
- const mergeRecommendation = nonEmptyString(metadata.merge_recommendation);
42
- if (mergeRecommendation) state.merge_recommendation = mergeRecommendation;
43
- if (typeof metadata.finalized === "boolean") state.finalized = metadata.finalized;
44
- return state;
45
- }
46
- function createRunResult(input) {
47
- const status = input.status || input.state.status;
48
- const ok = isSuccessfulStatus(status);
49
- const state = input.metadata ? applyTerminalMetadata(input.state, input.metadata) : input.state;
50
- state.status = status;
51
- state.ok = ok;
52
- return compactRecord({
53
- ok,
54
- status,
55
- run_id: state.run_id,
56
- state_path: input.state_path ?? state.state_path ?? null,
57
- worktree_path: state.worktree_path ?? null,
58
- branch: state.branch ?? null,
59
- current_stage: state.current_stage ?? null,
60
- iterations: state.iterations,
61
- last_checkpoint: state.last_checkpoint ?? null,
62
- last_summary: input.last_summary ?? null,
63
- event_count: state.events.length,
64
- pr_url: state.pr_url,
65
- marked_ready: state.marked_ready,
66
- notification: state.notification,
67
- proof_decision: state.proof_decision,
68
- merge_recommendation: state.merge_recommendation,
69
- finalized: state.finalized,
70
- blocker: state.blocker,
71
- evidence_bundle: input.evidence_bundle,
72
- raw: input.raw
73
- });
74
- }
75
-
76
- export {
77
- isTerminalStatus,
78
- isSuccessfulStatus,
79
- compactRecord,
80
- nonEmptyString,
81
- recordValue,
82
- normalizeTerminalMetadata,
83
- applyTerminalMetadata,
84
- createRunResult
85
- };