@riddledc/riddle-proof 0.8.58 → 0.8.60
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/adapters/codex-exec-agent.d.cts +1 -0
- package/dist/adapters/codex-exec-agent.d.ts +1 -0
- package/dist/adapters/codex-exec-agent.js +3 -2
- package/dist/adapters/codex.d.cts +1 -0
- package/dist/adapters/codex.d.ts +1 -0
- package/dist/adapters/codex.js +3 -2
- package/dist/adapters/local-agent.d.cts +1 -0
- package/dist/adapters/local-agent.d.ts +1 -0
- package/dist/adapters/local-agent.js +3 -2
- package/dist/adapters/openclaw.d.cts +1 -0
- package/dist/adapters/openclaw.d.ts +1 -0
- package/dist/adapters/openclaw.js +6 -5
- package/dist/advanced/engine-harness.cjs +253 -43
- package/dist/advanced/engine-harness.d.cts +1 -0
- package/dist/advanced/engine-harness.d.ts +1 -0
- package/dist/advanced/engine-harness.js +6 -5
- package/dist/advanced/index.cjs +253 -43
- package/dist/advanced/index.d.cts +1 -0
- package/dist/advanced/index.d.ts +1 -0
- package/dist/advanced/index.js +7 -6
- package/dist/advanced/runner.cjs +202 -4
- package/dist/advanced/runner.d.cts +1 -0
- package/dist/advanced/runner.d.ts +1 -0
- package/dist/advanced/runner.js +6 -5
- package/dist/checkpoint.d.cts +1 -0
- package/dist/checkpoint.d.ts +1 -0
- package/dist/checkpoint.js +3 -2
- package/dist/{chunk-TTB3ZAVX.js → chunk-3FK5HZHK.js} +2 -2
- package/dist/{chunk-ONOPGCID.js → chunk-AWRBSVNW.js} +4 -4
- package/dist/{chunk-MOTQNIZX.js → chunk-FX2CB4MG.js} +1 -1
- package/dist/{chunk-62XLYPMS.js → chunk-HZOILEGF.js} +15 -2
- package/dist/{chunk-KNPCWWF3.js → chunk-NXEAFQYZ.js} +16 -10
- package/dist/{chunk-GHBNDHG7.js → chunk-PCEDAQPG.js} +4 -4
- package/dist/{chunk-CUBYSWZT.js → chunk-QGMSN34W.js} +51 -4
- package/dist/{chunk-RS4HJLJQ.js → chunk-QPKY767W.js} +1 -1
- package/dist/{chunk-UZIX7M7D.js → chunk-UEY5SJG5.js} +13 -9
- package/dist/{chunk-KG64Y5MC.js → chunk-WKIIJX3O.js} +12 -0
- package/dist/{chunk-JLOZTVXU.js → chunk-XKNJ5OE4.js} +2 -2
- package/dist/cli/index.js +9 -9
- package/dist/cli.cjs +473 -403
- package/dist/cli.js +9 -9
- package/dist/codex-exec-agent.d.cts +1 -0
- package/dist/codex-exec-agent.d.ts +1 -0
- package/dist/codex-exec-agent.js +3 -2
- package/dist/diagnostics.d.cts +1 -0
- package/dist/diagnostics.d.ts +1 -0
- package/dist/engine-harness.cjs +253 -43
- package/dist/engine-harness.d.cts +1 -0
- package/dist/engine-harness.d.ts +1 -0
- package/dist/engine-harness.js +6 -5
- package/dist/index.cjs +248 -168
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +21 -11
- package/dist/local-agent.d.cts +1 -0
- package/dist/local-agent.d.ts +1 -0
- package/dist/local-agent.js +3 -2
- package/dist/openclaw.d.cts +1 -0
- package/dist/openclaw.d.ts +1 -0
- package/dist/openclaw.js +6 -5
- package/dist/pr-comment.cjs +19 -1
- package/dist/pr-comment.d.cts +2 -0
- package/dist/pr-comment.d.ts +2 -0
- package/dist/pr-comment.js +2 -2
- package/dist/profile/index.d.cts +1 -0
- package/dist/profile/index.d.ts +1 -0
- package/dist/profile.d.cts +1 -0
- package/dist/profile.d.ts +1 -0
- package/dist/proof-session.d.cts +1 -0
- package/dist/proof-session.d.ts +1 -0
- package/dist/public-state.cjs +15 -0
- package/dist/public-state.d.cts +4 -1
- package/dist/public-state.d.ts +4 -1
- package/dist/public-state.js +7 -1
- package/dist/result.cjs +211 -4
- package/dist/result.d.cts +12 -1
- package/dist/result.d.ts +12 -1
- package/dist/result.js +6 -1
- package/dist/run-card.cjs +198 -40
- package/dist/run-card.d.cts +1 -0
- package/dist/run-card.d.ts +1 -0
- package/dist/run-card.js +4 -3
- package/dist/runner.cjs +202 -4
- package/dist/runner.d.cts +1 -0
- package/dist/runner.d.ts +1 -0
- package/dist/runner.js +6 -5
- package/dist/spec/checkpoint.d.cts +1 -0
- package/dist/spec/checkpoint.d.ts +1 -0
- package/dist/spec/checkpoint.js +3 -2
- package/dist/spec/index.cjs +235 -167
- package/dist/spec/index.d.cts +2 -2
- package/dist/spec/index.d.ts +2 -2
- package/dist/spec/index.js +17 -7
- package/dist/spec/public-state.cjs +15 -0
- package/dist/spec/public-state.d.cts +1 -1
- package/dist/spec/public-state.d.ts +1 -1
- package/dist/spec/public-state.js +7 -1
- package/dist/spec/result.cjs +209 -4
- package/dist/spec/result.d.cts +2 -1
- package/dist/spec/result.d.ts +2 -1
- package/dist/spec/result.js +6 -1
- package/dist/spec/run-card.cjs +198 -40
- package/dist/spec/run-card.d.cts +1 -0
- package/dist/spec/run-card.d.ts +1 -0
- package/dist/spec/run-card.js +4 -3
- package/dist/spec/state.cjs +207 -45
- package/dist/spec/state.d.cts +1 -0
- package/dist/spec/state.d.ts +1 -0
- package/dist/spec/state.js +5 -4
- package/dist/spec/types.d.cts +1 -0
- package/dist/spec/types.d.ts +1 -0
- package/dist/state.cjs +207 -45
- package/dist/state.d.cts +1 -0
- package/dist/state.d.ts +1 -0
- package/dist/state.js +5 -4
- package/dist/types.d.cts +14 -0
- package/dist/types.d.ts +14 -0
- package/package.json +1 -1
package/dist/spec/result.cjs
CHANGED
|
@@ -29,11 +29,174 @@ __export(result_exports, {
|
|
|
29
29
|
isTerminalStatus: () => isTerminalStatus,
|
|
30
30
|
nonEmptyString: () => nonEmptyString,
|
|
31
31
|
normalizeTerminalMetadata: () => normalizeTerminalMetadata,
|
|
32
|
+
publicMergeRecommendationForRunState: () => publicMergeRecommendationForRunState,
|
|
33
|
+
publicStateForRunState: () => publicStateForRunState,
|
|
32
34
|
recordValue: () => recordValue,
|
|
33
35
|
shipControlStateFor: () => shipControlStateFor
|
|
34
36
|
});
|
|
35
37
|
module.exports = __toCommonJS(result_exports);
|
|
36
38
|
|
|
39
|
+
// src/public-state.ts
|
|
40
|
+
function riddleProofPublicStateAllowsClaim(summary, claim) {
|
|
41
|
+
return !summary?.prohibited_claims.includes(claim);
|
|
42
|
+
}
|
|
43
|
+
function riddleProofPublicStateAllowsMergeRecommendation(summary) {
|
|
44
|
+
return riddleProofPublicStateAllowsClaim(summary, "merge_ready") && riddleProofPublicStateAllowsClaim(summary, "sync_allowed");
|
|
45
|
+
}
|
|
46
|
+
function riddleProofPublicStateMergeRecommendation(summary, recommendation) {
|
|
47
|
+
return recommendation && riddleProofPublicStateAllowsMergeRecommendation(summary) ? recommendation : void 0;
|
|
48
|
+
}
|
|
49
|
+
function asRecord(value) {
|
|
50
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
51
|
+
}
|
|
52
|
+
function stringValue(value) {
|
|
53
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
54
|
+
}
|
|
55
|
+
function booleanValue(value) {
|
|
56
|
+
return typeof value === "boolean" ? value : void 0;
|
|
57
|
+
}
|
|
58
|
+
function numberValue(value) {
|
|
59
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
60
|
+
}
|
|
61
|
+
function firstStringValue(...values) {
|
|
62
|
+
for (const value of values) {
|
|
63
|
+
const text = stringValue(value);
|
|
64
|
+
if (text) return text;
|
|
65
|
+
}
|
|
66
|
+
return void 0;
|
|
67
|
+
}
|
|
68
|
+
function firstBooleanValue(...values) {
|
|
69
|
+
for (const value of values) {
|
|
70
|
+
const bool = booleanValue(value);
|
|
71
|
+
if (typeof bool === "boolean") return bool;
|
|
72
|
+
}
|
|
73
|
+
return void 0;
|
|
74
|
+
}
|
|
75
|
+
function firstRecordValue(...values) {
|
|
76
|
+
for (const value of values) {
|
|
77
|
+
const record = asRecord(value);
|
|
78
|
+
if (Object.keys(record).length) return record;
|
|
79
|
+
}
|
|
80
|
+
return void 0;
|
|
81
|
+
}
|
|
82
|
+
function countValue(value) {
|
|
83
|
+
const number = numberValue(value);
|
|
84
|
+
return typeof number === "number" && number > 0 ? Math.trunc(number) : 0;
|
|
85
|
+
}
|
|
86
|
+
function checkpointSummaryFrom(...values) {
|
|
87
|
+
const record = firstRecordValue(...values);
|
|
88
|
+
if (!record) return void 0;
|
|
89
|
+
const accepted = countValue(record.response_count);
|
|
90
|
+
const rejected = countValue(record.rejected_response_count);
|
|
91
|
+
const ignored = countValue(record.ignored_response_count);
|
|
92
|
+
const duplicate = countValue(record.duplicate_response_count);
|
|
93
|
+
const summary = {
|
|
94
|
+
pending: booleanValue(record.pending),
|
|
95
|
+
accepted_response_count: accepted,
|
|
96
|
+
rejected_response_count: rejected,
|
|
97
|
+
ignored_response_count: ignored,
|
|
98
|
+
duplicate_response_count: duplicate,
|
|
99
|
+
latest_decision: stringValue(record.latest_decision),
|
|
100
|
+
audit_disclosure_required: rejected > 0 || ignored > 0 || duplicate > 0
|
|
101
|
+
};
|
|
102
|
+
return Object.values(summary).some((value) => typeof value !== "undefined") ? summary : void 0;
|
|
103
|
+
}
|
|
104
|
+
function uniqueStrings(values) {
|
|
105
|
+
return [...new Set(values.filter(Boolean))];
|
|
106
|
+
}
|
|
107
|
+
function summarizeRiddleProofPublicState(input) {
|
|
108
|
+
const record = asRecord(input);
|
|
109
|
+
const runCard = asRecord(record.run_card);
|
|
110
|
+
const stopCondition = asRecord(runCard.stop_condition);
|
|
111
|
+
const raw = asRecord(record.raw);
|
|
112
|
+
const request = asRecord(record.request);
|
|
113
|
+
const requestMetadata = asRecord(record.request_metadata);
|
|
114
|
+
const prState = asRecord(record.pr_state);
|
|
115
|
+
const handoff = asRecord(record.pr_handoff_policy);
|
|
116
|
+
const handoffState = stringValue(handoff.state);
|
|
117
|
+
const status = firstStringValue(record.status, stopCondition.status);
|
|
118
|
+
const ok = booleanValue(record.ok) ?? null;
|
|
119
|
+
const shipMode = firstStringValue(request.ship_mode, requestMetadata.ship_mode, record.ship_mode, handoff.ship_mode);
|
|
120
|
+
const explicitShippingDisabled = firstBooleanValue(
|
|
121
|
+
record.shipping_disabled,
|
|
122
|
+
stopCondition.shipping_disabled,
|
|
123
|
+
raw.shipping_disabled,
|
|
124
|
+
handoff.shipping_disabled
|
|
125
|
+
);
|
|
126
|
+
const shippingDisabled = explicitShippingDisabled === true || shipMode === "none" || handoffState === "proof_complete_ship_disabled";
|
|
127
|
+
const explicitShipAuthorized = firstBooleanValue(
|
|
128
|
+
record.ship_authorized,
|
|
129
|
+
stopCondition.ship_authorized,
|
|
130
|
+
raw.ship_authorized
|
|
131
|
+
);
|
|
132
|
+
const authorizationEvidence = Boolean(
|
|
133
|
+
status === "shipped" || record.marked_ready === true || stringValue(prState.status) === "merged" || record.merge_commit || record.merged_at
|
|
134
|
+
);
|
|
135
|
+
const shipAuthorizedBeforeHold = explicitShipAuthorized ?? authorizationEvidence;
|
|
136
|
+
const explicitShipHeld = firstBooleanValue(record.ship_held, stopCondition.ship_held, raw.ship_held);
|
|
137
|
+
const inferredHeld = status === "ready_to_ship" && shippingDisabled && !shipAuthorizedBeforeHold;
|
|
138
|
+
const shipHeld = explicitShipHeld === true || inferredHeld;
|
|
139
|
+
const shipAuthorized = shipHeld ? false : shipAuthorizedBeforeHold === true;
|
|
140
|
+
const proofComplete = Boolean(
|
|
141
|
+
status === "ready_to_ship" || status === "shipped" || status === "completed" || status === "passed" || ok === true || handoff.proof_complete === true
|
|
142
|
+
);
|
|
143
|
+
const checkpointSummary = checkpointSummaryFrom(
|
|
144
|
+
record.checkpoint_summary,
|
|
145
|
+
stopCondition.checkpoint_summary,
|
|
146
|
+
asRecord(record.details).checkpoint_summary,
|
|
147
|
+
asRecord(raw.details).checkpoint_summary
|
|
148
|
+
);
|
|
149
|
+
const blockedOrWaiting = status === "blocked" || status === "failed" || status === "awaiting_checkpoint" || handoffState === "proof_blocked" || handoffState === "proof_review_required" || handoffState === "proof_failed" || handoffState === "proof_checkpoint_required";
|
|
150
|
+
const proofPassed = Boolean(proofComplete && !blockedOrWaiting);
|
|
151
|
+
const explicitMergeReady = firstBooleanValue(record.merge_ready, stopCondition.merge_ready, raw.merge_ready, handoff.merge_ready);
|
|
152
|
+
const normalPrAllowed = firstBooleanValue(record.normal_pr_allowed, raw.normal_pr_allowed, handoff.normal_pr_allowed);
|
|
153
|
+
const baseHandoffAllowed = !blockedOrWaiting && !shipHeld && !shippingDisabled;
|
|
154
|
+
const mergeReady = baseHandoffAllowed && normalPrAllowed !== false && (explicitMergeReady ?? shipAuthorized);
|
|
155
|
+
const syncAllowed = mergeReady;
|
|
156
|
+
let policyState = "unknown";
|
|
157
|
+
if (status === "awaiting_checkpoint" || handoffState === "proof_checkpoint_required") policyState = "awaiting_checkpoint";
|
|
158
|
+
else if (status === "failed" || handoffState === "proof_failed") policyState = "proof_failed";
|
|
159
|
+
else if (status === "blocked" || handoffState === "proof_blocked" || handoffState === "proof_review_required") policyState = "proof_blocked";
|
|
160
|
+
else if (handoffState === "proof_complete_ship_disabled") policyState = "proof_complete_ship_disabled";
|
|
161
|
+
else if (proofComplete && shipHeld && !shipAuthorized) policyState = "proof_passed_ship_held";
|
|
162
|
+
else if (proofComplete && shippingDisabled && !shipAuthorized) policyState = "proof_complete_ship_disabled";
|
|
163
|
+
else if (shipAuthorized) policyState = "ship_authorized";
|
|
164
|
+
else if (proofPassed) policyState = "proof_passed";
|
|
165
|
+
else if (status === "running") policyState = "proof_in_progress";
|
|
166
|
+
const requiredDisclosures = [];
|
|
167
|
+
if (shipHeld) requiredDisclosures.push("ship_held");
|
|
168
|
+
if (shippingDisabled) requiredDisclosures.push("shipping_disabled");
|
|
169
|
+
if (checkpointSummary?.audit_disclosure_required) requiredDisclosures.push("checkpoint_audit_counters");
|
|
170
|
+
if (status === "awaiting_checkpoint" || handoffState === "proof_checkpoint_required") requiredDisclosures.push("checkpoint_required");
|
|
171
|
+
const prohibitedClaims = [];
|
|
172
|
+
if (!shipAuthorized || shipHeld || shippingDisabled) prohibitedClaims.push("ship_authorized", "shipped");
|
|
173
|
+
if (!mergeReady) prohibitedClaims.push("merge_ready");
|
|
174
|
+
if (!syncAllowed) prohibitedClaims.push("sync_allowed");
|
|
175
|
+
if (blockedOrWaiting) {
|
|
176
|
+
prohibitedClaims.push("proof_passed", "ready_to_ship");
|
|
177
|
+
}
|
|
178
|
+
if (checkpointSummary?.audit_disclosure_required) {
|
|
179
|
+
prohibitedClaims.push("all_checkpoint_responses_accepted");
|
|
180
|
+
}
|
|
181
|
+
const resultLabel = policyState === "awaiting_checkpoint" ? "checkpoint required" : policyState === "proof_blocked" ? "blocked" : policyState === "proof_failed" ? "failed" : policyState === "proof_complete_ship_disabled" ? "proof complete; shipping disabled" : policyState === "proof_passed_ship_held" ? "proof passed; ship held" : policyState === "ship_authorized" ? status === "shipped" ? "shipped" : "ship authorized" : policyState === "proof_passed" ? "passed" : policyState === "proof_in_progress" ? "running" : status || "recorded";
|
|
182
|
+
return {
|
|
183
|
+
status,
|
|
184
|
+
ok,
|
|
185
|
+
policy_state: policyState,
|
|
186
|
+
result_label: resultLabel,
|
|
187
|
+
proof_complete: proofComplete,
|
|
188
|
+
proof_passed: proofPassed,
|
|
189
|
+
ship_held: shipHeld,
|
|
190
|
+
shipping_disabled: shippingDisabled,
|
|
191
|
+
ship_authorized: shipAuthorized,
|
|
192
|
+
merge_ready: mergeReady,
|
|
193
|
+
sync_allowed: syncAllowed,
|
|
194
|
+
checkpoint_summary: checkpointSummary,
|
|
195
|
+
required_disclosures: uniqueStrings(requiredDisclosures),
|
|
196
|
+
prohibited_claims: uniqueStrings(prohibitedClaims)
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
37
200
|
// src/result.ts
|
|
38
201
|
function isTerminalStatus(status) {
|
|
39
202
|
return status === "blocked" || status === "failed" || status === "ready_to_ship" || status === "shipped" || status === "completed";
|
|
@@ -208,6 +371,37 @@ function applyTerminalMetadata(state, metadata) {
|
|
|
208
371
|
if (typeof metadata.finalized === "boolean") state.finalized = metadata.finalized;
|
|
209
372
|
return state;
|
|
210
373
|
}
|
|
374
|
+
function publicStateForRunState(input) {
|
|
375
|
+
const state = input.state;
|
|
376
|
+
const status = input.status || state.status;
|
|
377
|
+
const raw = recordValue(input.raw) || {};
|
|
378
|
+
const extendedState = state;
|
|
379
|
+
const terminalOk = isTerminalStatus(status) ? state.ok : void 0;
|
|
380
|
+
return summarizeRiddleProofPublicState(compactRecord({
|
|
381
|
+
status,
|
|
382
|
+
ok: terminalOk,
|
|
383
|
+
request: state.request,
|
|
384
|
+
pr_state: state.pr_state,
|
|
385
|
+
marked_ready: state.marked_ready,
|
|
386
|
+
ship_held: state.ship_held,
|
|
387
|
+
shipping_disabled: state.shipping_disabled,
|
|
388
|
+
ship_authorized: state.ship_authorized,
|
|
389
|
+
ship_mode: state.request?.ship_mode,
|
|
390
|
+
merge_commit: state.merge_commit,
|
|
391
|
+
merged_at: state.merged_at,
|
|
392
|
+
checkpoint_summary: state.checkpoint_summary,
|
|
393
|
+
pr_handoff_policy: recordValue(extendedState.pr_handoff_policy),
|
|
394
|
+
merge_ready: extendedState.merge_ready,
|
|
395
|
+
normal_pr_allowed: extendedState.normal_pr_allowed,
|
|
396
|
+
raw: Object.keys(raw).length ? raw : void 0
|
|
397
|
+
}));
|
|
398
|
+
}
|
|
399
|
+
function publicMergeRecommendationForRunState(input) {
|
|
400
|
+
return riddleProofPublicStateMergeRecommendation(
|
|
401
|
+
publicStateForRunState(input),
|
|
402
|
+
input.state.merge_recommendation
|
|
403
|
+
);
|
|
404
|
+
}
|
|
211
405
|
function shipControlStateFor(input) {
|
|
212
406
|
const state = input.state;
|
|
213
407
|
const status = input.status || state.status;
|
|
@@ -256,6 +450,11 @@ function createRunResult(input) {
|
|
|
256
450
|
state.ok = ok;
|
|
257
451
|
if (isProtectedFinalStatus(status)) state.finalized = true;
|
|
258
452
|
applyShipControlState(state, { status, raw: input.raw });
|
|
453
|
+
const publicState = publicStateForRunState({ state, status, raw: input.raw });
|
|
454
|
+
const publicMergeRecommendation = riddleProofPublicStateMergeRecommendation(
|
|
455
|
+
publicState,
|
|
456
|
+
state.merge_recommendation
|
|
457
|
+
);
|
|
259
458
|
return compactRecord({
|
|
260
459
|
ok,
|
|
261
460
|
status,
|
|
@@ -273,9 +472,12 @@ function createRunResult(input) {
|
|
|
273
472
|
pr_state: state.pr_state,
|
|
274
473
|
marked_ready: state.marked_ready,
|
|
275
474
|
left_draft: state.left_draft,
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
475
|
+
result_label: publicState.result_label,
|
|
476
|
+
ship_held: publicState.ship_held,
|
|
477
|
+
shipping_disabled: publicState.shipping_disabled,
|
|
478
|
+
ship_authorized: publicState.ship_authorized,
|
|
479
|
+
merge_ready: publicState.merge_ready,
|
|
480
|
+
sync_allowed: publicState.sync_allowed,
|
|
279
481
|
ci_status: state.ci_status,
|
|
280
482
|
ship_commit: state.ship_commit,
|
|
281
483
|
ship_remote_head: state.ship_remote_head,
|
|
@@ -289,7 +491,8 @@ function createRunResult(input) {
|
|
|
289
491
|
cleanup_report: state.cleanup_report,
|
|
290
492
|
notification: state.notification,
|
|
291
493
|
proof_decision: state.proof_decision,
|
|
292
|
-
merge_recommendation:
|
|
494
|
+
merge_recommendation: publicMergeRecommendation,
|
|
495
|
+
public_state: publicState,
|
|
293
496
|
finalized: state.finalized,
|
|
294
497
|
blocker: state.blocker,
|
|
295
498
|
checkpoint_packet: state.checkpoint_packet,
|
|
@@ -314,6 +517,8 @@ function createRunResult(input) {
|
|
|
314
517
|
isTerminalStatus,
|
|
315
518
|
nonEmptyString,
|
|
316
519
|
normalizeTerminalMetadata,
|
|
520
|
+
publicMergeRecommendationForRunState,
|
|
521
|
+
publicStateForRunState,
|
|
317
522
|
recordValue,
|
|
318
523
|
shipControlStateFor
|
|
319
524
|
});
|
package/dist/spec/result.d.cts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { RiddleProofShipControlState, TerminalMetadataInput, applyShipControlState, applyTerminalMetadata, compactRecord, createRunResult, isProtectedFinalStatus, isSuccessfulStatus, isTerminalStatus, nonEmptyString, normalizeTerminalMetadata, recordValue, shipControlStateFor } from '../result.cjs';
|
|
1
|
+
export { RiddleProofShipControlState, TerminalMetadataInput, applyShipControlState, applyTerminalMetadata, compactRecord, createRunResult, isProtectedFinalStatus, isSuccessfulStatus, isTerminalStatus, nonEmptyString, normalizeTerminalMetadata, publicMergeRecommendationForRunState, publicStateForRunState, recordValue, shipControlStateFor } from '../result.cjs';
|
|
2
|
+
import '../public-state.cjs';
|
|
2
3
|
import '../types.cjs';
|
package/dist/spec/result.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { RiddleProofShipControlState, TerminalMetadataInput, applyShipControlState, applyTerminalMetadata, compactRecord, createRunResult, isProtectedFinalStatus, isSuccessfulStatus, isTerminalStatus, nonEmptyString, normalizeTerminalMetadata, recordValue, shipControlStateFor } from '../result.js';
|
|
1
|
+
export { RiddleProofShipControlState, TerminalMetadataInput, applyShipControlState, applyTerminalMetadata, compactRecord, createRunResult, isProtectedFinalStatus, isSuccessfulStatus, isTerminalStatus, nonEmptyString, normalizeTerminalMetadata, publicMergeRecommendationForRunState, publicStateForRunState, recordValue, shipControlStateFor } from '../result.js';
|
|
2
|
+
import '../public-state.js';
|
|
2
3
|
import '../types.js';
|
package/dist/spec/result.js
CHANGED
|
@@ -8,9 +8,12 @@ import {
|
|
|
8
8
|
isTerminalStatus,
|
|
9
9
|
nonEmptyString,
|
|
10
10
|
normalizeTerminalMetadata,
|
|
11
|
+
publicMergeRecommendationForRunState,
|
|
12
|
+
publicStateForRunState,
|
|
11
13
|
recordValue,
|
|
12
14
|
shipControlStateFor
|
|
13
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-QGMSN34W.js";
|
|
16
|
+
import "../chunk-WKIIJX3O.js";
|
|
14
17
|
import "../chunk-MLKGABMK.js";
|
|
15
18
|
export {
|
|
16
19
|
applyShipControlState,
|
|
@@ -22,6 +25,8 @@ export {
|
|
|
22
25
|
isTerminalStatus,
|
|
23
26
|
nonEmptyString,
|
|
24
27
|
normalizeTerminalMetadata,
|
|
28
|
+
publicMergeRecommendationForRunState,
|
|
29
|
+
publicStateForRunState,
|
|
25
30
|
recordValue,
|
|
26
31
|
shipControlStateFor
|
|
27
32
|
};
|
package/dist/spec/run-card.cjs
CHANGED
|
@@ -35,59 +35,212 @@ __export(run_card_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(run_card_exports);
|
|
37
37
|
|
|
38
|
-
// src/
|
|
39
|
-
function
|
|
40
|
-
return
|
|
38
|
+
// src/public-state.ts
|
|
39
|
+
function riddleProofPublicStateAllowsClaim(summary, claim) {
|
|
40
|
+
return !summary?.prohibited_claims.includes(claim);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
return
|
|
42
|
+
function riddleProofPublicStateAllowsMergeRecommendation(summary) {
|
|
43
|
+
return riddleProofPublicStateAllowsClaim(summary, "merge_ready") && riddleProofPublicStateAllowsClaim(summary, "sync_allowed");
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function riddleProofPublicStateMergeRecommendation(summary, recommendation) {
|
|
46
|
+
return recommendation && riddleProofPublicStateAllowsMergeRecommendation(summary) ? recommendation : void 0;
|
|
47
|
+
}
|
|
48
|
+
function asRecord(value) {
|
|
49
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
50
|
+
}
|
|
51
|
+
function stringValue(value) {
|
|
46
52
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
47
53
|
}
|
|
48
|
-
function
|
|
49
|
-
return
|
|
54
|
+
function booleanValue(value) {
|
|
55
|
+
return typeof value === "boolean" ? value : void 0;
|
|
56
|
+
}
|
|
57
|
+
function numberValue(value) {
|
|
58
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
50
59
|
}
|
|
51
|
-
function
|
|
60
|
+
function firstStringValue(...values) {
|
|
52
61
|
for (const value of values) {
|
|
53
|
-
|
|
62
|
+
const text = stringValue(value);
|
|
63
|
+
if (text) return text;
|
|
54
64
|
}
|
|
55
65
|
return void 0;
|
|
56
66
|
}
|
|
57
|
-
function
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
function firstBooleanValue(...values) {
|
|
68
|
+
for (const value of values) {
|
|
69
|
+
const bool = booleanValue(value);
|
|
70
|
+
if (typeof bool === "boolean") return bool;
|
|
71
|
+
}
|
|
72
|
+
return void 0;
|
|
73
|
+
}
|
|
74
|
+
function firstRecordValue(...values) {
|
|
75
|
+
for (const value of values) {
|
|
76
|
+
const record = asRecord(value);
|
|
77
|
+
if (Object.keys(record).length) return record;
|
|
78
|
+
}
|
|
79
|
+
return void 0;
|
|
80
|
+
}
|
|
81
|
+
function countValue(value) {
|
|
82
|
+
const number = numberValue(value);
|
|
83
|
+
return typeof number === "number" && number > 0 ? Math.trunc(number) : 0;
|
|
84
|
+
}
|
|
85
|
+
function checkpointSummaryFrom(...values) {
|
|
86
|
+
const record = firstRecordValue(...values);
|
|
87
|
+
if (!record) return void 0;
|
|
88
|
+
const accepted = countValue(record.response_count);
|
|
89
|
+
const rejected = countValue(record.rejected_response_count);
|
|
90
|
+
const ignored = countValue(record.ignored_response_count);
|
|
91
|
+
const duplicate = countValue(record.duplicate_response_count);
|
|
92
|
+
const summary = {
|
|
93
|
+
pending: booleanValue(record.pending),
|
|
94
|
+
accepted_response_count: accepted,
|
|
95
|
+
rejected_response_count: rejected,
|
|
96
|
+
ignored_response_count: ignored,
|
|
97
|
+
duplicate_response_count: duplicate,
|
|
98
|
+
latest_decision: stringValue(record.latest_decision),
|
|
99
|
+
audit_disclosure_required: rejected > 0 || ignored > 0 || duplicate > 0
|
|
100
|
+
};
|
|
101
|
+
return Object.values(summary).some((value) => typeof value !== "undefined") ? summary : void 0;
|
|
102
|
+
}
|
|
103
|
+
function uniqueStrings(values) {
|
|
104
|
+
return [...new Set(values.filter(Boolean))];
|
|
105
|
+
}
|
|
106
|
+
function summarizeRiddleProofPublicState(input) {
|
|
107
|
+
const record = asRecord(input);
|
|
108
|
+
const runCard = asRecord(record.run_card);
|
|
109
|
+
const stopCondition = asRecord(runCard.stop_condition);
|
|
110
|
+
const raw = asRecord(record.raw);
|
|
111
|
+
const request = asRecord(record.request);
|
|
112
|
+
const requestMetadata = asRecord(record.request_metadata);
|
|
113
|
+
const prState = asRecord(record.pr_state);
|
|
114
|
+
const handoff = asRecord(record.pr_handoff_policy);
|
|
115
|
+
const handoffState = stringValue(handoff.state);
|
|
116
|
+
const status = firstStringValue(record.status, stopCondition.status);
|
|
117
|
+
const ok = booleanValue(record.ok) ?? null;
|
|
118
|
+
const shipMode = firstStringValue(request.ship_mode, requestMetadata.ship_mode, record.ship_mode, handoff.ship_mode);
|
|
119
|
+
const explicitShippingDisabled = firstBooleanValue(
|
|
120
|
+
record.shipping_disabled,
|
|
121
|
+
stopCondition.shipping_disabled,
|
|
64
122
|
raw.shipping_disabled,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
raw.ship_authorized
|
|
72
|
-
raw.shipAuthorized,
|
|
73
|
-
state.ship_authorized,
|
|
74
|
-
shipReport.ship_authorized,
|
|
75
|
-
shipReport.shipAuthorized
|
|
123
|
+
handoff.shipping_disabled
|
|
124
|
+
);
|
|
125
|
+
const shippingDisabled = explicitShippingDisabled === true || shipMode === "none" || handoffState === "proof_complete_ship_disabled";
|
|
126
|
+
const explicitShipAuthorized = firstBooleanValue(
|
|
127
|
+
record.ship_authorized,
|
|
128
|
+
stopCondition.ship_authorized,
|
|
129
|
+
raw.ship_authorized
|
|
76
130
|
);
|
|
77
131
|
const authorizationEvidence = Boolean(
|
|
78
|
-
status === "shipped" ||
|
|
132
|
+
status === "shipped" || record.marked_ready === true || stringValue(prState.status) === "merged" || record.merge_commit || record.merged_at
|
|
133
|
+
);
|
|
134
|
+
const shipAuthorizedBeforeHold = explicitShipAuthorized ?? authorizationEvidence;
|
|
135
|
+
const explicitShipHeld = firstBooleanValue(record.ship_held, stopCondition.ship_held, raw.ship_held);
|
|
136
|
+
const inferredHeld = status === "ready_to_ship" && shippingDisabled && !shipAuthorizedBeforeHold;
|
|
137
|
+
const shipHeld = explicitShipHeld === true || inferredHeld;
|
|
138
|
+
const shipAuthorized = shipHeld ? false : shipAuthorizedBeforeHold === true;
|
|
139
|
+
const proofComplete = Boolean(
|
|
140
|
+
status === "ready_to_ship" || status === "shipped" || status === "completed" || status === "passed" || ok === true || handoff.proof_complete === true
|
|
79
141
|
);
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
142
|
+
const checkpointSummary = checkpointSummaryFrom(
|
|
143
|
+
record.checkpoint_summary,
|
|
144
|
+
stopCondition.checkpoint_summary,
|
|
145
|
+
asRecord(record.details).checkpoint_summary,
|
|
146
|
+
asRecord(raw.details).checkpoint_summary
|
|
147
|
+
);
|
|
148
|
+
const blockedOrWaiting = status === "blocked" || status === "failed" || status === "awaiting_checkpoint" || handoffState === "proof_blocked" || handoffState === "proof_review_required" || handoffState === "proof_failed" || handoffState === "proof_checkpoint_required";
|
|
149
|
+
const proofPassed = Boolean(proofComplete && !blockedOrWaiting);
|
|
150
|
+
const explicitMergeReady = firstBooleanValue(record.merge_ready, stopCondition.merge_ready, raw.merge_ready, handoff.merge_ready);
|
|
151
|
+
const normalPrAllowed = firstBooleanValue(record.normal_pr_allowed, raw.normal_pr_allowed, handoff.normal_pr_allowed);
|
|
152
|
+
const baseHandoffAllowed = !blockedOrWaiting && !shipHeld && !shippingDisabled;
|
|
153
|
+
const mergeReady = baseHandoffAllowed && normalPrAllowed !== false && (explicitMergeReady ?? shipAuthorized);
|
|
154
|
+
const syncAllowed = mergeReady;
|
|
155
|
+
let policyState = "unknown";
|
|
156
|
+
if (status === "awaiting_checkpoint" || handoffState === "proof_checkpoint_required") policyState = "awaiting_checkpoint";
|
|
157
|
+
else if (status === "failed" || handoffState === "proof_failed") policyState = "proof_failed";
|
|
158
|
+
else if (status === "blocked" || handoffState === "proof_blocked" || handoffState === "proof_review_required") policyState = "proof_blocked";
|
|
159
|
+
else if (handoffState === "proof_complete_ship_disabled") policyState = "proof_complete_ship_disabled";
|
|
160
|
+
else if (proofComplete && shipHeld && !shipAuthorized) policyState = "proof_passed_ship_held";
|
|
161
|
+
else if (proofComplete && shippingDisabled && !shipAuthorized) policyState = "proof_complete_ship_disabled";
|
|
162
|
+
else if (shipAuthorized) policyState = "ship_authorized";
|
|
163
|
+
else if (proofPassed) policyState = "proof_passed";
|
|
164
|
+
else if (status === "running") policyState = "proof_in_progress";
|
|
165
|
+
const requiredDisclosures = [];
|
|
166
|
+
if (shipHeld) requiredDisclosures.push("ship_held");
|
|
167
|
+
if (shippingDisabled) requiredDisclosures.push("shipping_disabled");
|
|
168
|
+
if (checkpointSummary?.audit_disclosure_required) requiredDisclosures.push("checkpoint_audit_counters");
|
|
169
|
+
if (status === "awaiting_checkpoint" || handoffState === "proof_checkpoint_required") requiredDisclosures.push("checkpoint_required");
|
|
170
|
+
const prohibitedClaims = [];
|
|
171
|
+
if (!shipAuthorized || shipHeld || shippingDisabled) prohibitedClaims.push("ship_authorized", "shipped");
|
|
172
|
+
if (!mergeReady) prohibitedClaims.push("merge_ready");
|
|
173
|
+
if (!syncAllowed) prohibitedClaims.push("sync_allowed");
|
|
174
|
+
if (blockedOrWaiting) {
|
|
175
|
+
prohibitedClaims.push("proof_passed", "ready_to_ship");
|
|
176
|
+
}
|
|
177
|
+
if (checkpointSummary?.audit_disclosure_required) {
|
|
178
|
+
prohibitedClaims.push("all_checkpoint_responses_accepted");
|
|
179
|
+
}
|
|
180
|
+
const resultLabel = policyState === "awaiting_checkpoint" ? "checkpoint required" : policyState === "proof_blocked" ? "blocked" : policyState === "proof_failed" ? "failed" : policyState === "proof_complete_ship_disabled" ? "proof complete; shipping disabled" : policyState === "proof_passed_ship_held" ? "proof passed; ship held" : policyState === "ship_authorized" ? status === "shipped" ? "shipped" : "ship authorized" : policyState === "proof_passed" ? "passed" : policyState === "proof_in_progress" ? "running" : status || "recorded";
|
|
84
181
|
return {
|
|
182
|
+
status,
|
|
183
|
+
ok,
|
|
184
|
+
policy_state: policyState,
|
|
185
|
+
result_label: resultLabel,
|
|
186
|
+
proof_complete: proofComplete,
|
|
187
|
+
proof_passed: proofPassed,
|
|
85
188
|
ship_held: shipHeld,
|
|
86
189
|
shipping_disabled: shippingDisabled,
|
|
87
|
-
ship_authorized:
|
|
190
|
+
ship_authorized: shipAuthorized,
|
|
191
|
+
merge_ready: mergeReady,
|
|
192
|
+
sync_allowed: syncAllowed,
|
|
193
|
+
checkpoint_summary: checkpointSummary,
|
|
194
|
+
required_disclosures: uniqueStrings(requiredDisclosures),
|
|
195
|
+
prohibited_claims: uniqueStrings(prohibitedClaims)
|
|
88
196
|
};
|
|
89
197
|
}
|
|
90
198
|
|
|
199
|
+
// src/result.ts
|
|
200
|
+
function isTerminalStatus(status) {
|
|
201
|
+
return status === "blocked" || status === "failed" || status === "ready_to_ship" || status === "shipped" || status === "completed";
|
|
202
|
+
}
|
|
203
|
+
function compactRecord(input) {
|
|
204
|
+
return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0 && value !== null && value !== ""));
|
|
205
|
+
}
|
|
206
|
+
function nonEmptyString(value) {
|
|
207
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
208
|
+
}
|
|
209
|
+
function recordValue(value) {
|
|
210
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
211
|
+
}
|
|
212
|
+
function publicStateForRunState(input) {
|
|
213
|
+
const state = input.state;
|
|
214
|
+
const status = input.status || state.status;
|
|
215
|
+
const raw = recordValue(input.raw) || {};
|
|
216
|
+
const extendedState = state;
|
|
217
|
+
const terminalOk = isTerminalStatus(status) ? state.ok : void 0;
|
|
218
|
+
return summarizeRiddleProofPublicState(compactRecord({
|
|
219
|
+
status,
|
|
220
|
+
ok: terminalOk,
|
|
221
|
+
request: state.request,
|
|
222
|
+
pr_state: state.pr_state,
|
|
223
|
+
marked_ready: state.marked_ready,
|
|
224
|
+
ship_held: state.ship_held,
|
|
225
|
+
shipping_disabled: state.shipping_disabled,
|
|
226
|
+
ship_authorized: state.ship_authorized,
|
|
227
|
+
ship_mode: state.request?.ship_mode,
|
|
228
|
+
merge_commit: state.merge_commit,
|
|
229
|
+
merged_at: state.merged_at,
|
|
230
|
+
checkpoint_summary: state.checkpoint_summary,
|
|
231
|
+
pr_handoff_policy: recordValue(extendedState.pr_handoff_policy),
|
|
232
|
+
merge_ready: extendedState.merge_ready,
|
|
233
|
+
normal_pr_allowed: extendedState.normal_pr_allowed,
|
|
234
|
+
raw: Object.keys(raw).length ? raw : void 0
|
|
235
|
+
}));
|
|
236
|
+
}
|
|
237
|
+
function publicMergeRecommendationForRunState(input) {
|
|
238
|
+
return riddleProofPublicStateMergeRecommendation(
|
|
239
|
+
publicStateForRunState(input),
|
|
240
|
+
input.state.merge_recommendation
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
|
|
91
244
|
// src/checkpoint.ts
|
|
92
245
|
var import_node_crypto = __toESM(require("crypto"), 1);
|
|
93
246
|
function statePathsForRunState(state, engineStatePath) {
|
|
@@ -257,7 +410,8 @@ function createRiddleProofRunCard(state, input = {}) {
|
|
|
257
410
|
const visualDelta = visualDeltaFrom({ fullRiddleState: fullState, runState: state });
|
|
258
411
|
const artifacts = artifactsFrom({ fullRiddleState: fullState, runState: state });
|
|
259
412
|
const viewportMatrix = viewportMatrixFrom({ fullRiddleState: fullState, runState: state });
|
|
260
|
-
const
|
|
413
|
+
const publicState = publicStateForRunState({ state, status: state.status });
|
|
414
|
+
const publicMergeRecommendation = publicMergeRecommendationForRunState({ state, status: state.status });
|
|
261
415
|
return {
|
|
262
416
|
version: RIDDLE_PROOF_RUN_CARD_VERSION,
|
|
263
417
|
run_id: state.run_id || "unknown",
|
|
@@ -311,14 +465,18 @@ function createRiddleProofRunCard(state, input = {}) {
|
|
|
311
465
|
stop_condition: compactRecord({
|
|
312
466
|
status: state.status,
|
|
313
467
|
terminal: isTerminalStatus(state.status),
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
468
|
+
result_label: publicState.result_label,
|
|
469
|
+
ship_held: publicState.ship_held,
|
|
470
|
+
shipping_disabled: publicState.shipping_disabled,
|
|
471
|
+
ship_authorized: publicState.ship_authorized,
|
|
472
|
+
merge_ready: publicState.merge_ready,
|
|
473
|
+
sync_allowed: publicState.sync_allowed,
|
|
317
474
|
blocker_code: state.blocker?.code || null,
|
|
318
475
|
blocker_message: state.blocker?.message || null,
|
|
319
476
|
proof_decision: state.proof_decision,
|
|
320
|
-
merge_recommendation:
|
|
321
|
-
monitor_should_continue: !isTerminalStatus(state.status)
|
|
477
|
+
merge_recommendation: publicMergeRecommendation,
|
|
478
|
+
monitor_should_continue: !isTerminalStatus(state.status),
|
|
479
|
+
public_state: publicState
|
|
322
480
|
}),
|
|
323
481
|
updated_at: state.updated_at
|
|
324
482
|
};
|
package/dist/spec/run-card.d.cts
CHANGED
package/dist/spec/run-card.d.ts
CHANGED
package/dist/spec/run-card.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RIDDLE_PROOF_RUN_CARD_VERSION,
|
|
3
3
|
createRiddleProofRunCard
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-NXEAFQYZ.js";
|
|
5
|
+
import "../chunk-FX2CB4MG.js";
|
|
6
|
+
import "../chunk-QGMSN34W.js";
|
|
7
|
+
import "../chunk-WKIIJX3O.js";
|
|
7
8
|
import "../chunk-MLKGABMK.js";
|
|
8
9
|
export {
|
|
9
10
|
RIDDLE_PROOF_RUN_CARD_VERSION,
|