@riddledc/riddle-proof 0.2.0 → 0.3.0

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.cjs CHANGED
@@ -59,7 +59,11 @@ function createRunResult(input) {
59
59
  return compactRecord({
60
60
  ok,
61
61
  status,
62
+ run_id: state.run_id,
62
63
  state_path: input.state_path ?? state.state_path ?? null,
64
+ worktree_path: state.worktree_path ?? null,
65
+ branch: state.branch ?? null,
66
+ current_stage: state.current_stage ?? null,
63
67
  iterations: state.iterations,
64
68
  last_checkpoint: state.last_checkpoint ?? null,
65
69
  last_summary: input.last_summary ?? null,
@@ -81,6 +85,17 @@ var RIDDLE_PROOF_RUN_STATE_VERSION = "riddle-proof.run-state.v1";
81
85
  function timestamp() {
82
86
  return (/* @__PURE__ */ new Date()).toISOString();
83
87
  }
88
+ function createRunId(createdAt) {
89
+ const stamp = createdAt.replace(/\D/g, "").slice(0, 14) || "unknown";
90
+ const entropy = Math.random().toString(36).slice(2, 8) || "run";
91
+ return `rp_${stamp}_${entropy}`;
92
+ }
93
+ function elapsedMs(start, end) {
94
+ const startMs = start ? Date.parse(start) : NaN;
95
+ const endMs = end ? Date.parse(end) : NaN;
96
+ if (!Number.isFinite(startMs) || !Number.isFinite(endMs)) return void 0;
97
+ return Math.max(0, endMs - startMs);
98
+ }
84
99
  function normalizeIntegrationContext(input, fallbackSource) {
85
100
  const value = recordValue(input);
86
101
  if (!value) {
@@ -131,7 +146,12 @@ function createRunState(input) {
131
146
  const createdAt = input.created_at || timestamp();
132
147
  return compactRecord({
133
148
  version: RIDDLE_PROOF_RUN_STATE_VERSION,
149
+ run_id: input.run_id || createRunId(createdAt),
134
150
  state_path: input.state_path,
151
+ worktree_path: input.worktree_path,
152
+ branch: input.branch || input.request.branch,
153
+ current_stage: input.current_stage ?? null,
154
+ stage_started_at: input.stage_started_at ?? null,
135
155
  status: input.status || "running",
136
156
  created_at: createdAt,
137
157
  updated_at: input.updated_at || createdAt,
@@ -159,9 +179,30 @@ function appendRunEvent(state, input) {
159
179
  details: event.details
160
180
  }));
161
181
  if (input.checkpoint !== void 0) state.last_checkpoint = input.checkpoint;
182
+ if (input.stage !== void 0) {
183
+ if (state.current_stage !== input.stage) state.stage_started_at = event.ts;
184
+ state.current_stage = input.stage;
185
+ }
162
186
  state.updated_at = event.ts;
163
187
  return state;
164
188
  }
189
+ function appendStageHeartbeat(state, input) {
190
+ const at = input.ts || timestamp();
191
+ return appendRunEvent(state, {
192
+ ts: at,
193
+ kind: "stage.heartbeat",
194
+ checkpoint: input.checkpoint || `${input.stage}_heartbeat`,
195
+ stage: input.stage,
196
+ summary: input.summary || `${input.stage} stage is active.`,
197
+ details: compactRecord({
198
+ elapsed_ms: elapsedMs(state.created_at, at),
199
+ stage_elapsed_ms: elapsedMs(state.stage_started_at, at),
200
+ wait_reason: input.wait_reason,
201
+ blocker: input.blocker,
202
+ ...input.details
203
+ })
204
+ });
205
+ }
165
206
  function setRunStatus(state, status, at = timestamp()) {
166
207
  state.status = status;
167
208
  state.ok = status !== "blocked" && status !== "failed";
@@ -246,7 +287,8 @@ async function notifyIfConfigured(input) {
246
287
  async function runRiddleProof(input) {
247
288
  const state = input.state || createRunState({
248
289
  request: input.request,
249
- state_path: input.state_path
290
+ state_path: input.state_path,
291
+ worktree_path: input.workdir
250
292
  });
251
293
  const adapters = input.adapters || {};
252
294
  const maxIterations = Math.max(1, Math.trunc(input.max_iterations ?? 1));
@@ -256,12 +298,70 @@ async function runRiddleProof(input) {
256
298
  stage: "setup",
257
299
  summary: "Riddle Proof run started.",
258
300
  details: {
301
+ run_id: state.run_id,
302
+ state_path: state.state_path,
303
+ worktree_path: state.worktree_path,
304
+ branch: state.branch,
259
305
  max_iterations: maxIterations,
260
306
  ship_mode: state.request.ship_mode || "none"
261
307
  }
262
308
  });
309
+ appendStageHeartbeat(state, {
310
+ stage: "setup",
311
+ summary: "Setup stage is active.",
312
+ details: {
313
+ run_id: state.run_id,
314
+ state_path: state.state_path,
315
+ worktree_path: state.worktree_path,
316
+ branch: state.branch
317
+ }
318
+ });
263
319
  let workdir = input.workdir;
264
320
  let evidenceContext;
321
+ if (adapters.preflight) {
322
+ appendRunEvent(state, {
323
+ kind: "preflight.started",
324
+ checkpoint: "preflight_started",
325
+ stage: "preflight",
326
+ summary: "Riddle Proof preflight adapter started."
327
+ });
328
+ try {
329
+ const preflight = await adapters.preflight.preflight({ request: state.request, state });
330
+ if (!preflight.ok) {
331
+ return blockRun({
332
+ state,
333
+ stage: "preflight",
334
+ blocker: adapterBlocker(
335
+ "preflight_failed",
336
+ "The preflight adapter found blocking tool or model configuration issues.",
337
+ "preflight_failed",
338
+ {
339
+ blockers: preflight.blockers,
340
+ warnings: preflight.warnings,
341
+ degraded_capabilities: preflight.degraded_capabilities
342
+ }
343
+ ),
344
+ raw: { preflight }
345
+ });
346
+ }
347
+ appendRunEvent(state, {
348
+ kind: "preflight.completed",
349
+ checkpoint: "preflight_completed",
350
+ stage: "preflight",
351
+ summary: "Riddle Proof preflight adapter completed.",
352
+ details: {
353
+ warnings: preflight.warnings,
354
+ degraded_capabilities: preflight.degraded_capabilities
355
+ }
356
+ });
357
+ } catch (error) {
358
+ return blockRun({
359
+ state,
360
+ stage: "preflight",
361
+ blocker: adapterBlocker("preflight_exception", "The preflight adapter threw an exception.", "preflight_failed", errorDetails(error))
362
+ });
363
+ }
364
+ }
265
365
  if (adapters.setup) {
266
366
  appendRunEvent(state, {
267
367
  kind: "setup.started",
@@ -284,7 +384,9 @@ async function runRiddleProof(input) {
284
384
  raw: { setup }
285
385
  });
286
386
  }
287
- workdir = setup.workdir || workdir;
387
+ workdir = setup.worktree_path || setup.workdir || workdir;
388
+ state.worktree_path = setup.worktree_path || setup.workdir || state.worktree_path;
389
+ state.branch = setup.branch || state.branch;
288
390
  evidenceContext = setup.evidence_context;
289
391
  appendRunEvent(state, {
290
392
  kind: "setup.completed",
@@ -293,6 +395,9 @@ async function runRiddleProof(input) {
293
395
  summary: "Riddle Proof setup adapter completed.",
294
396
  details: {
295
397
  has_workdir: Boolean(workdir),
398
+ worktree_path: state.worktree_path,
399
+ branch: state.branch,
400
+ cleanup_policy: setup.cleanup_policy,
296
401
  has_evidence_context: Boolean(evidenceContext)
297
402
  }
298
403
  });
@@ -345,6 +450,11 @@ async function runRiddleProof(input) {
345
450
  let assessment;
346
451
  for (let attempt = 0; attempt < maxIterations; attempt += 1) {
347
452
  state.iterations += 1;
453
+ appendStageHeartbeat(state, {
454
+ stage: "implement",
455
+ summary: "Implementation stage is active.",
456
+ details: { iteration: state.iterations }
457
+ });
348
458
  appendRunEvent(state, {
349
459
  kind: "implementation.started",
350
460
  checkpoint: "implementation_started",
@@ -391,6 +501,13 @@ async function runRiddleProof(input) {
391
501
  tests_run: implementation.tests_run
392
502
  }
393
503
  });
504
+ appendStageHeartbeat(state, {
505
+ stage: "prove",
506
+ summary: "Proof capture stage is active.",
507
+ details: {
508
+ verification_mode: state.request.verification_mode
509
+ }
510
+ });
394
511
  appendRunEvent(state, {
395
512
  kind: "proof.started",
396
513
  checkpoint: "proof_started",
@@ -440,6 +557,13 @@ async function runRiddleProof(input) {
440
557
  stage: "verify",
441
558
  summary: "Judge adapter started."
442
559
  });
560
+ appendStageHeartbeat(state, {
561
+ stage: "verify",
562
+ summary: "Verification stage is active.",
563
+ details: {
564
+ verification_mode: evidenceBundle.verification_mode
565
+ }
566
+ });
443
567
  try {
444
568
  assessment = await adapters.judge.assessProof({ state, evidence_bundle: evidenceBundle });
445
569
  state.proof_decision = assessment.decision;
@@ -529,6 +653,10 @@ async function runRiddleProof(input) {
529
653
  stage: "ship",
530
654
  summary: "Ship adapter started."
531
655
  });
656
+ appendStageHeartbeat(state, {
657
+ stage: "ship",
658
+ summary: "Ship stage is active."
659
+ });
532
660
  let metadata;
533
661
  try {
534
662
  metadata = await adapters.ship.ship({ state, assessment });
package/dist/runner.d.cts CHANGED
@@ -1,6 +1,7 @@
1
- import { SetupAdapter, ImplementationAdapter, ProofAdapter, JudgeAdapter, ShipAdapter, NotificationAdapter, RiddleProofRunParams, RiddleProofRunState, RiddleProofRunResult } from './types.cjs';
1
+ import { PreflightAdapter, SetupAdapter, ImplementationAdapter, ProofAdapter, JudgeAdapter, ShipAdapter, NotificationAdapter, RiddleProofRunParams, RiddleProofRunState, RiddleProofRunResult } from './types.cjs';
2
2
 
3
3
  interface RiddleProofRunnerAdapters {
4
+ preflight?: PreflightAdapter;
4
5
  setup?: SetupAdapter;
5
6
  implementation?: ImplementationAdapter;
6
7
  proof?: ProofAdapter;
package/dist/runner.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { SetupAdapter, ImplementationAdapter, ProofAdapter, JudgeAdapter, ShipAdapter, NotificationAdapter, RiddleProofRunParams, RiddleProofRunState, RiddleProofRunResult } from './types.js';
1
+ import { PreflightAdapter, SetupAdapter, ImplementationAdapter, ProofAdapter, JudgeAdapter, ShipAdapter, NotificationAdapter, RiddleProofRunParams, RiddleProofRunState, RiddleProofRunResult } from './types.js';
2
2
 
3
3
  interface RiddleProofRunnerAdapters {
4
+ preflight?: PreflightAdapter;
4
5
  setup?: SetupAdapter;
5
6
  implementation?: ImplementationAdapter;
6
7
  proof?: ProofAdapter;
package/dist/runner.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  runRiddleProof
3
- } from "./chunk-GWGXPNON.js";
4
- import "./chunk-EPVZKWUS.js";
5
- import "./chunk-2ZQNXVQC.js";
3
+ } from "./chunk-P3FUU5X4.js";
4
+ import "./chunk-IQIEOQZF.js";
5
+ import "./chunk-5DC6YXN4.js";
6
6
  export {
7
7
  runRiddleProof
8
8
  };
package/dist/state.cjs CHANGED
@@ -22,7 +22,9 @@ var state_exports = {};
22
22
  __export(state_exports, {
23
23
  RIDDLE_PROOF_RUN_STATE_VERSION: () => RIDDLE_PROOF_RUN_STATE_VERSION,
24
24
  appendRunEvent: () => appendRunEvent,
25
+ appendStageHeartbeat: () => appendStageHeartbeat,
25
26
  createRunState: () => createRunState,
27
+ createRunStatusSnapshot: () => createRunStatusSnapshot,
26
28
  normalizeIntegrationContext: () => normalizeIntegrationContext,
27
29
  normalizeRunParams: () => normalizeRunParams,
28
30
  setRunStatus: () => setRunStatus
@@ -45,6 +47,17 @@ var RIDDLE_PROOF_RUN_STATE_VERSION = "riddle-proof.run-state.v1";
45
47
  function timestamp() {
46
48
  return (/* @__PURE__ */ new Date()).toISOString();
47
49
  }
50
+ function createRunId(createdAt) {
51
+ const stamp = createdAt.replace(/\D/g, "").slice(0, 14) || "unknown";
52
+ const entropy = Math.random().toString(36).slice(2, 8) || "run";
53
+ return `rp_${stamp}_${entropy}`;
54
+ }
55
+ function elapsedMs(start, end) {
56
+ const startMs = start ? Date.parse(start) : NaN;
57
+ const endMs = end ? Date.parse(end) : NaN;
58
+ if (!Number.isFinite(startMs) || !Number.isFinite(endMs)) return void 0;
59
+ return Math.max(0, endMs - startMs);
60
+ }
48
61
  function normalizeIntegrationContext(input, fallbackSource) {
49
62
  const value = recordValue(input);
50
63
  if (!value) {
@@ -95,7 +108,12 @@ function createRunState(input) {
95
108
  const createdAt = input.created_at || timestamp();
96
109
  return compactRecord({
97
110
  version: RIDDLE_PROOF_RUN_STATE_VERSION,
111
+ run_id: input.run_id || createRunId(createdAt),
98
112
  state_path: input.state_path,
113
+ worktree_path: input.worktree_path,
114
+ branch: input.branch || input.request.branch,
115
+ current_stage: input.current_stage ?? null,
116
+ stage_started_at: input.stage_started_at ?? null,
99
117
  status: input.status || "running",
100
118
  created_at: createdAt,
101
119
  updated_at: input.updated_at || createdAt,
@@ -123,9 +141,49 @@ function appendRunEvent(state, input) {
123
141
  details: event.details
124
142
  }));
125
143
  if (input.checkpoint !== void 0) state.last_checkpoint = input.checkpoint;
144
+ if (input.stage !== void 0) {
145
+ if (state.current_stage !== input.stage) state.stage_started_at = event.ts;
146
+ state.current_stage = input.stage;
147
+ }
126
148
  state.updated_at = event.ts;
127
149
  return state;
128
150
  }
151
+ function appendStageHeartbeat(state, input) {
152
+ const at = input.ts || timestamp();
153
+ return appendRunEvent(state, {
154
+ ts: at,
155
+ kind: "stage.heartbeat",
156
+ checkpoint: input.checkpoint || `${input.stage}_heartbeat`,
157
+ stage: input.stage,
158
+ summary: input.summary || `${input.stage} stage is active.`,
159
+ details: compactRecord({
160
+ elapsed_ms: elapsedMs(state.created_at, at),
161
+ stage_elapsed_ms: elapsedMs(state.stage_started_at, at),
162
+ wait_reason: input.wait_reason,
163
+ blocker: input.blocker,
164
+ ...input.details
165
+ })
166
+ });
167
+ }
168
+ function createRunStatusSnapshot(state, at = timestamp()) {
169
+ const latestEvent = state.events[state.events.length - 1];
170
+ const runId = state.run_id || "unknown";
171
+ return compactRecord({
172
+ run_id: runId,
173
+ status: state.status,
174
+ current_stage: state.current_stage ?? null,
175
+ state_path: state.state_path ?? null,
176
+ worktree_path: state.worktree_path ?? null,
177
+ branch: state.branch ?? null,
178
+ iterations: state.iterations,
179
+ last_checkpoint: state.last_checkpoint ?? null,
180
+ updated_at: state.updated_at,
181
+ elapsed_ms: elapsedMs(state.created_at, at),
182
+ stage_elapsed_ms: elapsedMs(state.stage_started_at, at),
183
+ blocker: state.blocker,
184
+ latest_event: latestEvent
185
+ });
186
+ }
129
187
  function setRunStatus(state, status, at = timestamp()) {
130
188
  state.status = status;
131
189
  state.ok = status !== "blocked" && status !== "failed";
@@ -136,7 +194,9 @@ function setRunStatus(state, status, at = timestamp()) {
136
194
  0 && (module.exports = {
137
195
  RIDDLE_PROOF_RUN_STATE_VERSION,
138
196
  appendRunEvent,
197
+ appendStageHeartbeat,
139
198
  createRunState,
199
+ createRunStatusSnapshot,
140
200
  normalizeIntegrationContext,
141
201
  normalizeRunParams,
142
202
  setRunStatus
package/dist/state.d.cts CHANGED
@@ -1,10 +1,15 @@
1
- import { RiddleProofRunParams, RiddleProofStatus, RiddleProofEvent, RiddleProofRunState, IntegrationContext } from './types.cjs';
1
+ import { RiddleProofRunParams, RiddleProofStatus, RiddleProofStage, RiddleProofEvent, RiddleProofRunState, 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 {
5
5
  request: RiddleProofRunParams;
6
+ run_id?: string;
6
7
  status?: RiddleProofStatus;
7
8
  state_path?: string;
9
+ worktree_path?: string;
10
+ branch?: string;
11
+ current_stage?: RiddleProofStage | null;
12
+ stage_started_at?: string | null;
8
13
  created_at?: string;
9
14
  updated_at?: string;
10
15
  iterations?: number;
@@ -18,6 +23,16 @@ declare function normalizeIntegrationContext(input?: Partial<IntegrationContext>
18
23
  declare function normalizeRunParams(input: RiddleProofRunParams): RiddleProofRunParams;
19
24
  declare function createRunState(input: CreateRunStateInput): RiddleProofRunState;
20
25
  declare function appendRunEvent<T extends RiddleProofRunState>(state: T, input: RunEventInput): T;
26
+ declare function appendStageHeartbeat<T extends RiddleProofRunState>(state: T, input: {
27
+ stage: RiddleProofStage;
28
+ summary?: string;
29
+ checkpoint?: string;
30
+ wait_reason?: string;
31
+ blocker?: string;
32
+ details?: Record<string, unknown>;
33
+ ts?: string;
34
+ }): T;
35
+ declare function createRunStatusSnapshot(state: RiddleProofRunState, at?: string): RiddleProofRunStatusSnapshot;
21
36
  declare function setRunStatus<T extends RiddleProofRunState>(state: T, status: RiddleProofStatus, at?: string): T;
22
37
 
23
- export { type CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, type RunEventInput, appendRunEvent, createRunState, normalizeIntegrationContext, normalizeRunParams, setRunStatus };
38
+ export { type CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, type RunEventInput, appendRunEvent, appendStageHeartbeat, createRunState, createRunStatusSnapshot, normalizeIntegrationContext, normalizeRunParams, setRunStatus };
package/dist/state.d.ts CHANGED
@@ -1,10 +1,15 @@
1
- import { RiddleProofRunParams, RiddleProofStatus, RiddleProofEvent, RiddleProofRunState, IntegrationContext } from './types.js';
1
+ import { RiddleProofRunParams, RiddleProofStatus, RiddleProofStage, RiddleProofEvent, RiddleProofRunState, 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 {
5
5
  request: RiddleProofRunParams;
6
+ run_id?: string;
6
7
  status?: RiddleProofStatus;
7
8
  state_path?: string;
9
+ worktree_path?: string;
10
+ branch?: string;
11
+ current_stage?: RiddleProofStage | null;
12
+ stage_started_at?: string | null;
8
13
  created_at?: string;
9
14
  updated_at?: string;
10
15
  iterations?: number;
@@ -18,6 +23,16 @@ declare function normalizeIntegrationContext(input?: Partial<IntegrationContext>
18
23
  declare function normalizeRunParams(input: RiddleProofRunParams): RiddleProofRunParams;
19
24
  declare function createRunState(input: CreateRunStateInput): RiddleProofRunState;
20
25
  declare function appendRunEvent<T extends RiddleProofRunState>(state: T, input: RunEventInput): T;
26
+ declare function appendStageHeartbeat<T extends RiddleProofRunState>(state: T, input: {
27
+ stage: RiddleProofStage;
28
+ summary?: string;
29
+ checkpoint?: string;
30
+ wait_reason?: string;
31
+ blocker?: string;
32
+ details?: Record<string, unknown>;
33
+ ts?: string;
34
+ }): T;
35
+ declare function createRunStatusSnapshot(state: RiddleProofRunState, at?: string): RiddleProofRunStatusSnapshot;
21
36
  declare function setRunStatus<T extends RiddleProofRunState>(state: T, status: RiddleProofStatus, at?: string): T;
22
37
 
23
- export { type CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, type RunEventInput, appendRunEvent, createRunState, normalizeIntegrationContext, normalizeRunParams, setRunStatus };
38
+ export { type CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, type RunEventInput, appendRunEvent, appendStageHeartbeat, createRunState, createRunStatusSnapshot, normalizeIntegrationContext, normalizeRunParams, setRunStatus };
package/dist/state.js CHANGED
@@ -1,16 +1,20 @@
1
1
  import {
2
2
  RIDDLE_PROOF_RUN_STATE_VERSION,
3
3
  appendRunEvent,
4
+ appendStageHeartbeat,
4
5
  createRunState,
6
+ createRunStatusSnapshot,
5
7
  normalizeIntegrationContext,
6
8
  normalizeRunParams,
7
9
  setRunStatus
8
- } from "./chunk-EPVZKWUS.js";
9
- import "./chunk-2ZQNXVQC.js";
10
+ } from "./chunk-IQIEOQZF.js";
11
+ import "./chunk-5DC6YXN4.js";
10
12
  export {
11
13
  RIDDLE_PROOF_RUN_STATE_VERSION,
12
14
  appendRunEvent,
15
+ appendStageHeartbeat,
13
16
  createRunState,
17
+ createRunStatusSnapshot,
14
18
  normalizeIntegrationContext,
15
19
  normalizeRunParams,
16
20
  setRunStatus
package/dist/types.d.cts CHANGED
@@ -6,7 +6,8 @@ type JsonObject = {
6
6
  type RiddleProofStatus = "running" | "blocked" | "failed" | "ready_to_ship" | "shipped" | "completed";
7
7
  type RiddleProofVerificationMode = "proof" | "visual" | "interaction" | "render" | "data" | "json" | "audio" | "log" | "logs" | "metric" | "metrics" | (string & {});
8
8
  type RiddleProofDecision = "ready_to_ship" | "needs_richer_proof" | "revise_capture" | "needs_recon" | "needs_implementation" | (string & {});
9
- type RiddleProofStage = "setup" | "recon" | "author" | "implement" | "prove" | "verify" | "ship" | "notify" | (string & {});
9
+ type RiddleProofStage = "preflight" | "setup" | "recon" | "author" | "implement" | "prove" | "verify" | "ship" | "notify" | (string & {});
10
+ type RiddleProofArtifactRole = "baseline" | "after_proof" | "incidental" | "diagnostic" | (string & {});
10
11
  interface RiddleProofRunParams {
11
12
  repo?: string;
12
13
  branch?: string;
@@ -60,7 +61,12 @@ interface RiddleProofEvent {
60
61
  }
61
62
  interface RiddleProofRunState {
62
63
  version: "riddle-proof.run-state.v1";
64
+ run_id?: string;
63
65
  state_path?: string;
66
+ worktree_path?: string;
67
+ branch?: string;
68
+ current_stage?: RiddleProofStage | null;
69
+ stage_started_at?: string | null;
64
70
  status: RiddleProofStatus;
65
71
  ok?: boolean;
66
72
  created_at: string;
@@ -80,7 +86,11 @@ interface RiddleProofRunState {
80
86
  interface RiddleProofRunResult {
81
87
  ok: boolean;
82
88
  status: RiddleProofStatus;
89
+ run_id?: string;
83
90
  state_path?: string | null;
91
+ worktree_path?: string | null;
92
+ branch?: string | null;
93
+ current_stage?: RiddleProofStage | null;
84
94
  iterations?: number;
85
95
  last_checkpoint?: string | null;
86
96
  last_summary?: string | null;
@@ -95,6 +105,21 @@ interface RiddleProofRunResult {
95
105
  evidence_bundle?: RiddleProofEvidenceBundle;
96
106
  raw?: Record<string, unknown>;
97
107
  }
108
+ interface RiddleProofRunStatusSnapshot {
109
+ run_id: string;
110
+ status: RiddleProofStatus;
111
+ current_stage?: RiddleProofStage | null;
112
+ state_path?: string | null;
113
+ worktree_path?: string | null;
114
+ branch?: string | null;
115
+ iterations: number;
116
+ last_checkpoint?: string | null;
117
+ updated_at: string;
118
+ elapsed_ms?: number;
119
+ stage_elapsed_ms?: number;
120
+ blocker?: RiddleProofBlocker;
121
+ latest_event?: RiddleProofEvent;
122
+ }
98
123
  interface RiddleProofEvidenceBundle {
99
124
  verification_mode: RiddleProofVerificationMode;
100
125
  baselines?: EvidenceReference[];
@@ -108,6 +133,7 @@ interface RiddleProofEvidenceBundle {
108
133
  }
109
134
  interface EvidenceReference {
110
135
  kind: "before" | "prod" | "after" | "comparison" | (string & {});
136
+ role?: RiddleProofArtifactRole;
111
137
  url?: string;
112
138
  path?: string;
113
139
  observed_path?: string;
@@ -117,6 +143,7 @@ interface EvidenceReference {
117
143
  interface EvidenceArtifact {
118
144
  name: string;
119
145
  kind?: "screenshot" | "json" | "log" | "metric" | "audio" | "video" | (string & {});
146
+ role?: RiddleProofArtifactRole;
120
147
  url?: string;
121
148
  path?: string;
122
149
  content_type?: string;
@@ -132,6 +159,20 @@ interface RiddleProofAssessment {
132
159
  reasons?: string[];
133
160
  source?: "supervising_agent" | "supervisor" | "human" | (string & {});
134
161
  }
162
+ interface PreflightAdapterInput {
163
+ request: RiddleProofRunParams;
164
+ state: RiddleProofRunState;
165
+ }
166
+ interface PreflightAdapterResult {
167
+ ok: boolean;
168
+ warnings?: string[];
169
+ degraded_capabilities?: string[];
170
+ blockers?: string[];
171
+ raw?: Record<string, unknown>;
172
+ }
173
+ interface PreflightAdapter {
174
+ preflight(input: PreflightAdapterInput): Promise<PreflightAdapterResult>;
175
+ }
135
176
  interface SetupAdapterInput {
136
177
  request: RiddleProofRunParams;
137
178
  state: RiddleProofRunState;
@@ -139,6 +180,9 @@ interface SetupAdapterInput {
139
180
  interface SetupAdapterResult {
140
181
  ok: boolean;
141
182
  workdir?: string;
183
+ worktree_path?: string;
184
+ branch?: string;
185
+ cleanup_policy?: "reuse" | "delete_on_success" | "delete_on_finish" | "leave_for_debug" | (string & {});
142
186
  evidence_context?: RiddleProofEvidenceBundle;
143
187
  blockers?: string[];
144
188
  raw?: Record<string, unknown>;
@@ -204,4 +248,4 @@ interface RiddleProofTerminalMetadata {
204
248
  finalized?: boolean;
205
249
  }
206
250
 
207
- export type { EvidenceArtifact, EvidenceReference, ImplementationAdapter, ImplementationAdapterInput, ImplementationAdapterResult, IntegrationContext, JsonObject, JsonPrimitive, JsonValue, JudgeAdapter, NotificationAdapter, ProofAdapter, ProofAdapterInput, ProofAdapterResult, RiddleProofAssessment, RiddleProofBlocker, RiddleProofDecision, RiddleProofEvent, RiddleProofEvidenceBundle, RiddleProofRunParams, RiddleProofRunResult, RiddleProofRunState, RiddleProofStage, RiddleProofStatus, RiddleProofTerminalMetadata, RiddleProofVerificationMode, SetupAdapter, SetupAdapterInput, SetupAdapterResult, ShipAdapter };
251
+ 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 };
package/dist/types.d.ts CHANGED
@@ -6,7 +6,8 @@ type JsonObject = {
6
6
  type RiddleProofStatus = "running" | "blocked" | "failed" | "ready_to_ship" | "shipped" | "completed";
7
7
  type RiddleProofVerificationMode = "proof" | "visual" | "interaction" | "render" | "data" | "json" | "audio" | "log" | "logs" | "metric" | "metrics" | (string & {});
8
8
  type RiddleProofDecision = "ready_to_ship" | "needs_richer_proof" | "revise_capture" | "needs_recon" | "needs_implementation" | (string & {});
9
- type RiddleProofStage = "setup" | "recon" | "author" | "implement" | "prove" | "verify" | "ship" | "notify" | (string & {});
9
+ type RiddleProofStage = "preflight" | "setup" | "recon" | "author" | "implement" | "prove" | "verify" | "ship" | "notify" | (string & {});
10
+ type RiddleProofArtifactRole = "baseline" | "after_proof" | "incidental" | "diagnostic" | (string & {});
10
11
  interface RiddleProofRunParams {
11
12
  repo?: string;
12
13
  branch?: string;
@@ -60,7 +61,12 @@ interface RiddleProofEvent {
60
61
  }
61
62
  interface RiddleProofRunState {
62
63
  version: "riddle-proof.run-state.v1";
64
+ run_id?: string;
63
65
  state_path?: string;
66
+ worktree_path?: string;
67
+ branch?: string;
68
+ current_stage?: RiddleProofStage | null;
69
+ stage_started_at?: string | null;
64
70
  status: RiddleProofStatus;
65
71
  ok?: boolean;
66
72
  created_at: string;
@@ -80,7 +86,11 @@ interface RiddleProofRunState {
80
86
  interface RiddleProofRunResult {
81
87
  ok: boolean;
82
88
  status: RiddleProofStatus;
89
+ run_id?: string;
83
90
  state_path?: string | null;
91
+ worktree_path?: string | null;
92
+ branch?: string | null;
93
+ current_stage?: RiddleProofStage | null;
84
94
  iterations?: number;
85
95
  last_checkpoint?: string | null;
86
96
  last_summary?: string | null;
@@ -95,6 +105,21 @@ interface RiddleProofRunResult {
95
105
  evidence_bundle?: RiddleProofEvidenceBundle;
96
106
  raw?: Record<string, unknown>;
97
107
  }
108
+ interface RiddleProofRunStatusSnapshot {
109
+ run_id: string;
110
+ status: RiddleProofStatus;
111
+ current_stage?: RiddleProofStage | null;
112
+ state_path?: string | null;
113
+ worktree_path?: string | null;
114
+ branch?: string | null;
115
+ iterations: number;
116
+ last_checkpoint?: string | null;
117
+ updated_at: string;
118
+ elapsed_ms?: number;
119
+ stage_elapsed_ms?: number;
120
+ blocker?: RiddleProofBlocker;
121
+ latest_event?: RiddleProofEvent;
122
+ }
98
123
  interface RiddleProofEvidenceBundle {
99
124
  verification_mode: RiddleProofVerificationMode;
100
125
  baselines?: EvidenceReference[];
@@ -108,6 +133,7 @@ interface RiddleProofEvidenceBundle {
108
133
  }
109
134
  interface EvidenceReference {
110
135
  kind: "before" | "prod" | "after" | "comparison" | (string & {});
136
+ role?: RiddleProofArtifactRole;
111
137
  url?: string;
112
138
  path?: string;
113
139
  observed_path?: string;
@@ -117,6 +143,7 @@ interface EvidenceReference {
117
143
  interface EvidenceArtifact {
118
144
  name: string;
119
145
  kind?: "screenshot" | "json" | "log" | "metric" | "audio" | "video" | (string & {});
146
+ role?: RiddleProofArtifactRole;
120
147
  url?: string;
121
148
  path?: string;
122
149
  content_type?: string;
@@ -132,6 +159,20 @@ interface RiddleProofAssessment {
132
159
  reasons?: string[];
133
160
  source?: "supervising_agent" | "supervisor" | "human" | (string & {});
134
161
  }
162
+ interface PreflightAdapterInput {
163
+ request: RiddleProofRunParams;
164
+ state: RiddleProofRunState;
165
+ }
166
+ interface PreflightAdapterResult {
167
+ ok: boolean;
168
+ warnings?: string[];
169
+ degraded_capabilities?: string[];
170
+ blockers?: string[];
171
+ raw?: Record<string, unknown>;
172
+ }
173
+ interface PreflightAdapter {
174
+ preflight(input: PreflightAdapterInput): Promise<PreflightAdapterResult>;
175
+ }
135
176
  interface SetupAdapterInput {
136
177
  request: RiddleProofRunParams;
137
178
  state: RiddleProofRunState;
@@ -139,6 +180,9 @@ interface SetupAdapterInput {
139
180
  interface SetupAdapterResult {
140
181
  ok: boolean;
141
182
  workdir?: string;
183
+ worktree_path?: string;
184
+ branch?: string;
185
+ cleanup_policy?: "reuse" | "delete_on_success" | "delete_on_finish" | "leave_for_debug" | (string & {});
142
186
  evidence_context?: RiddleProofEvidenceBundle;
143
187
  blockers?: string[];
144
188
  raw?: Record<string, unknown>;
@@ -204,4 +248,4 @@ interface RiddleProofTerminalMetadata {
204
248
  finalized?: boolean;
205
249
  }
206
250
 
207
- export type { EvidenceArtifact, EvidenceReference, ImplementationAdapter, ImplementationAdapterInput, ImplementationAdapterResult, IntegrationContext, JsonObject, JsonPrimitive, JsonValue, JudgeAdapter, NotificationAdapter, ProofAdapter, ProofAdapterInput, ProofAdapterResult, RiddleProofAssessment, RiddleProofBlocker, RiddleProofDecision, RiddleProofEvent, RiddleProofEvidenceBundle, RiddleProofRunParams, RiddleProofRunResult, RiddleProofRunState, RiddleProofStage, RiddleProofStatus, RiddleProofTerminalMetadata, RiddleProofVerificationMode, SetupAdapter, SetupAdapterInput, SetupAdapterResult, ShipAdapter };
251
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",