@riddledc/riddle-proof 0.8.56 → 0.8.58
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/{chunk-6KYXX4OE.js → chunk-62XLYPMS.js} +93 -2
- package/dist/chunk-KG64Y5MC.js +155 -0
- package/dist/{chunk-54DIEDR3.js → chunk-ONOPGCID.js} +1 -1
- package/dist/cli/index.js +3 -2
- package/dist/cli.cjs +266 -27
- package/dist/cli.js +3 -2
- package/dist/index.cjs +554 -313
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +5 -1
- package/dist/pr-comment.cjs +268 -27
- package/dist/pr-comment.d.cts +21 -1
- package/dist/pr-comment.d.ts +21 -1
- package/dist/pr-comment.js +2 -1
- package/dist/public-state.cjs +179 -0
- package/dist/public-state.d.cts +29 -0
- package/dist/public-state.d.ts +29 -0
- package/dist/public-state.js +7 -0
- package/dist/spec/index.cjs +156 -2
- package/dist/spec/index.d.cts +1 -0
- package/dist/spec/index.d.ts +1 -0
- package/dist/spec/index.js +5 -1
- package/dist/spec/public-state.cjs +181 -0
- package/dist/spec/public-state.d.cts +1 -0
- package/dist/spec/public-state.d.ts +1 -0
- package/dist/spec/public-state.js +7 -0
- package/package.json +12 -2
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/public-state.ts
|
|
21
|
+
var public_state_exports = {};
|
|
22
|
+
__export(public_state_exports, {
|
|
23
|
+
summarizeRiddleProofPublicState: () => summarizeRiddleProofPublicState
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(public_state_exports);
|
|
26
|
+
function asRecord(value) {
|
|
27
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
28
|
+
}
|
|
29
|
+
function stringValue(value) {
|
|
30
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
31
|
+
}
|
|
32
|
+
function booleanValue(value) {
|
|
33
|
+
return typeof value === "boolean" ? value : void 0;
|
|
34
|
+
}
|
|
35
|
+
function numberValue(value) {
|
|
36
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
37
|
+
}
|
|
38
|
+
function firstStringValue(...values) {
|
|
39
|
+
for (const value of values) {
|
|
40
|
+
const text = stringValue(value);
|
|
41
|
+
if (text) return text;
|
|
42
|
+
}
|
|
43
|
+
return void 0;
|
|
44
|
+
}
|
|
45
|
+
function firstBooleanValue(...values) {
|
|
46
|
+
for (const value of values) {
|
|
47
|
+
const bool = booleanValue(value);
|
|
48
|
+
if (typeof bool === "boolean") return bool;
|
|
49
|
+
}
|
|
50
|
+
return void 0;
|
|
51
|
+
}
|
|
52
|
+
function firstRecordValue(...values) {
|
|
53
|
+
for (const value of values) {
|
|
54
|
+
const record = asRecord(value);
|
|
55
|
+
if (Object.keys(record).length) return record;
|
|
56
|
+
}
|
|
57
|
+
return void 0;
|
|
58
|
+
}
|
|
59
|
+
function countValue(value) {
|
|
60
|
+
const number = numberValue(value);
|
|
61
|
+
return typeof number === "number" && number > 0 ? Math.trunc(number) : 0;
|
|
62
|
+
}
|
|
63
|
+
function checkpointSummaryFrom(...values) {
|
|
64
|
+
const record = firstRecordValue(...values);
|
|
65
|
+
if (!record) return void 0;
|
|
66
|
+
const accepted = countValue(record.response_count);
|
|
67
|
+
const rejected = countValue(record.rejected_response_count);
|
|
68
|
+
const ignored = countValue(record.ignored_response_count);
|
|
69
|
+
const duplicate = countValue(record.duplicate_response_count);
|
|
70
|
+
const summary = {
|
|
71
|
+
pending: booleanValue(record.pending),
|
|
72
|
+
accepted_response_count: accepted,
|
|
73
|
+
rejected_response_count: rejected,
|
|
74
|
+
ignored_response_count: ignored,
|
|
75
|
+
duplicate_response_count: duplicate,
|
|
76
|
+
latest_decision: stringValue(record.latest_decision),
|
|
77
|
+
audit_disclosure_required: rejected > 0 || ignored > 0 || duplicate > 0
|
|
78
|
+
};
|
|
79
|
+
return Object.values(summary).some((value) => typeof value !== "undefined") ? summary : void 0;
|
|
80
|
+
}
|
|
81
|
+
function uniqueStrings(values) {
|
|
82
|
+
return [...new Set(values.filter(Boolean))];
|
|
83
|
+
}
|
|
84
|
+
function summarizeRiddleProofPublicState(input) {
|
|
85
|
+
const record = asRecord(input);
|
|
86
|
+
const runCard = asRecord(record.run_card);
|
|
87
|
+
const stopCondition = asRecord(runCard.stop_condition);
|
|
88
|
+
const raw = asRecord(record.raw);
|
|
89
|
+
const request = asRecord(record.request);
|
|
90
|
+
const requestMetadata = asRecord(record.request_metadata);
|
|
91
|
+
const prState = asRecord(record.pr_state);
|
|
92
|
+
const handoff = asRecord(record.pr_handoff_policy);
|
|
93
|
+
const handoffState = stringValue(handoff.state);
|
|
94
|
+
const status = firstStringValue(record.status, stopCondition.status);
|
|
95
|
+
const ok = booleanValue(record.ok) ?? null;
|
|
96
|
+
const shipMode = firstStringValue(request.ship_mode, requestMetadata.ship_mode, record.ship_mode, handoff.ship_mode);
|
|
97
|
+
const explicitShippingDisabled = firstBooleanValue(
|
|
98
|
+
record.shipping_disabled,
|
|
99
|
+
stopCondition.shipping_disabled,
|
|
100
|
+
raw.shipping_disabled,
|
|
101
|
+
handoff.shipping_disabled
|
|
102
|
+
);
|
|
103
|
+
const shippingDisabled = explicitShippingDisabled === true || shipMode === "none" || handoffState === "proof_complete_ship_disabled";
|
|
104
|
+
const explicitShipAuthorized = firstBooleanValue(
|
|
105
|
+
record.ship_authorized,
|
|
106
|
+
stopCondition.ship_authorized,
|
|
107
|
+
raw.ship_authorized
|
|
108
|
+
);
|
|
109
|
+
const authorizationEvidence = Boolean(
|
|
110
|
+
status === "shipped" || record.marked_ready === true || stringValue(prState.status) === "merged" || record.merge_commit || record.merged_at
|
|
111
|
+
);
|
|
112
|
+
const shipAuthorizedBeforeHold = explicitShipAuthorized ?? authorizationEvidence;
|
|
113
|
+
const explicitShipHeld = firstBooleanValue(record.ship_held, stopCondition.ship_held, raw.ship_held);
|
|
114
|
+
const inferredHeld = status === "ready_to_ship" && shippingDisabled && !shipAuthorizedBeforeHold;
|
|
115
|
+
const shipHeld = explicitShipHeld === true || inferredHeld;
|
|
116
|
+
const shipAuthorized = shipHeld ? false : shipAuthorizedBeforeHold === true;
|
|
117
|
+
const proofComplete = Boolean(
|
|
118
|
+
status === "ready_to_ship" || status === "shipped" || status === "completed" || status === "passed" || ok === true || handoff.proof_complete === true
|
|
119
|
+
);
|
|
120
|
+
const checkpointSummary = checkpointSummaryFrom(
|
|
121
|
+
record.checkpoint_summary,
|
|
122
|
+
stopCondition.checkpoint_summary,
|
|
123
|
+
asRecord(record.details).checkpoint_summary,
|
|
124
|
+
asRecord(raw.details).checkpoint_summary
|
|
125
|
+
);
|
|
126
|
+
const blockedOrWaiting = status === "blocked" || status === "failed" || status === "awaiting_checkpoint" || handoffState === "proof_blocked" || handoffState === "proof_review_required" || handoffState === "proof_failed" || handoffState === "proof_checkpoint_required";
|
|
127
|
+
const proofPassed = Boolean(proofComplete && !blockedOrWaiting);
|
|
128
|
+
const explicitMergeReady = firstBooleanValue(record.merge_ready, stopCondition.merge_ready, raw.merge_ready, handoff.merge_ready);
|
|
129
|
+
const normalPrAllowed = firstBooleanValue(record.normal_pr_allowed, raw.normal_pr_allowed, handoff.normal_pr_allowed);
|
|
130
|
+
const baseHandoffAllowed = !blockedOrWaiting && !shipHeld && !shippingDisabled;
|
|
131
|
+
const mergeReady = baseHandoffAllowed && normalPrAllowed !== false && (explicitMergeReady ?? shipAuthorized);
|
|
132
|
+
const syncAllowed = mergeReady;
|
|
133
|
+
let policyState = "unknown";
|
|
134
|
+
if (status === "awaiting_checkpoint" || handoffState === "proof_checkpoint_required") policyState = "awaiting_checkpoint";
|
|
135
|
+
else if (status === "failed" || handoffState === "proof_failed") policyState = "proof_failed";
|
|
136
|
+
else if (status === "blocked" || handoffState === "proof_blocked" || handoffState === "proof_review_required") policyState = "proof_blocked";
|
|
137
|
+
else if (handoffState === "proof_complete_ship_disabled") policyState = "proof_complete_ship_disabled";
|
|
138
|
+
else if (proofComplete && shipHeld && !shipAuthorized) policyState = "proof_passed_ship_held";
|
|
139
|
+
else if (proofComplete && shippingDisabled && !shipAuthorized) policyState = "proof_complete_ship_disabled";
|
|
140
|
+
else if (shipAuthorized) policyState = "ship_authorized";
|
|
141
|
+
else if (proofPassed) policyState = "proof_passed";
|
|
142
|
+
else if (status === "running") policyState = "proof_in_progress";
|
|
143
|
+
const requiredDisclosures = [];
|
|
144
|
+
if (shipHeld) requiredDisclosures.push("ship_held");
|
|
145
|
+
if (shippingDisabled) requiredDisclosures.push("shipping_disabled");
|
|
146
|
+
if (checkpointSummary?.audit_disclosure_required) requiredDisclosures.push("checkpoint_audit_counters");
|
|
147
|
+
if (status === "awaiting_checkpoint" || handoffState === "proof_checkpoint_required") requiredDisclosures.push("checkpoint_required");
|
|
148
|
+
const prohibitedClaims = [];
|
|
149
|
+
if (!shipAuthorized || shipHeld || shippingDisabled) prohibitedClaims.push("ship_authorized", "shipped");
|
|
150
|
+
if (!mergeReady) prohibitedClaims.push("merge_ready");
|
|
151
|
+
if (!syncAllowed) prohibitedClaims.push("sync_allowed");
|
|
152
|
+
if (blockedOrWaiting) {
|
|
153
|
+
prohibitedClaims.push("proof_passed", "ready_to_ship");
|
|
154
|
+
}
|
|
155
|
+
if (checkpointSummary?.audit_disclosure_required) {
|
|
156
|
+
prohibitedClaims.push("all_checkpoint_responses_accepted");
|
|
157
|
+
}
|
|
158
|
+
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";
|
|
159
|
+
return {
|
|
160
|
+
status,
|
|
161
|
+
ok,
|
|
162
|
+
policy_state: policyState,
|
|
163
|
+
result_label: resultLabel,
|
|
164
|
+
proof_complete: proofComplete,
|
|
165
|
+
proof_passed: proofPassed,
|
|
166
|
+
ship_held: shipHeld,
|
|
167
|
+
shipping_disabled: shippingDisabled,
|
|
168
|
+
ship_authorized: shipAuthorized,
|
|
169
|
+
merge_ready: mergeReady,
|
|
170
|
+
sync_allowed: syncAllowed,
|
|
171
|
+
checkpoint_summary: checkpointSummary,
|
|
172
|
+
required_disclosures: uniqueStrings(requiredDisclosures),
|
|
173
|
+
prohibited_claims: uniqueStrings(prohibitedClaims)
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
177
|
+
0 && (module.exports = {
|
|
178
|
+
summarizeRiddleProofPublicState
|
|
179
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type RiddleProofPublicPolicyState = "awaiting_checkpoint" | "proof_blocked" | "proof_failed" | "proof_complete_ship_disabled" | "proof_passed_ship_held" | "ship_authorized" | "proof_passed" | "proof_in_progress" | "unknown";
|
|
2
|
+
interface RiddleProofPublicCheckpointSummary {
|
|
3
|
+
pending?: boolean;
|
|
4
|
+
accepted_response_count: number;
|
|
5
|
+
rejected_response_count: number;
|
|
6
|
+
ignored_response_count: number;
|
|
7
|
+
duplicate_response_count: number;
|
|
8
|
+
latest_decision?: string;
|
|
9
|
+
audit_disclosure_required: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface RiddleProofPublicStateSummary {
|
|
12
|
+
status?: string;
|
|
13
|
+
ok: boolean | null;
|
|
14
|
+
policy_state: RiddleProofPublicPolicyState;
|
|
15
|
+
result_label: string;
|
|
16
|
+
proof_complete: boolean;
|
|
17
|
+
proof_passed: boolean;
|
|
18
|
+
ship_held: boolean;
|
|
19
|
+
shipping_disabled: boolean;
|
|
20
|
+
ship_authorized: boolean;
|
|
21
|
+
merge_ready: boolean;
|
|
22
|
+
sync_allowed: boolean;
|
|
23
|
+
checkpoint_summary?: RiddleProofPublicCheckpointSummary;
|
|
24
|
+
required_disclosures: string[];
|
|
25
|
+
prohibited_claims: string[];
|
|
26
|
+
}
|
|
27
|
+
declare function summarizeRiddleProofPublicState(input: unknown): RiddleProofPublicStateSummary;
|
|
28
|
+
|
|
29
|
+
export { type RiddleProofPublicCheckpointSummary, type RiddleProofPublicPolicyState, type RiddleProofPublicStateSummary, summarizeRiddleProofPublicState };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type RiddleProofPublicPolicyState = "awaiting_checkpoint" | "proof_blocked" | "proof_failed" | "proof_complete_ship_disabled" | "proof_passed_ship_held" | "ship_authorized" | "proof_passed" | "proof_in_progress" | "unknown";
|
|
2
|
+
interface RiddleProofPublicCheckpointSummary {
|
|
3
|
+
pending?: boolean;
|
|
4
|
+
accepted_response_count: number;
|
|
5
|
+
rejected_response_count: number;
|
|
6
|
+
ignored_response_count: number;
|
|
7
|
+
duplicate_response_count: number;
|
|
8
|
+
latest_decision?: string;
|
|
9
|
+
audit_disclosure_required: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface RiddleProofPublicStateSummary {
|
|
12
|
+
status?: string;
|
|
13
|
+
ok: boolean | null;
|
|
14
|
+
policy_state: RiddleProofPublicPolicyState;
|
|
15
|
+
result_label: string;
|
|
16
|
+
proof_complete: boolean;
|
|
17
|
+
proof_passed: boolean;
|
|
18
|
+
ship_held: boolean;
|
|
19
|
+
shipping_disabled: boolean;
|
|
20
|
+
ship_authorized: boolean;
|
|
21
|
+
merge_ready: boolean;
|
|
22
|
+
sync_allowed: boolean;
|
|
23
|
+
checkpoint_summary?: RiddleProofPublicCheckpointSummary;
|
|
24
|
+
required_disclosures: string[];
|
|
25
|
+
prohibited_claims: string[];
|
|
26
|
+
}
|
|
27
|
+
declare function summarizeRiddleProofPublicState(input: unknown): RiddleProofPublicStateSummary;
|
|
28
|
+
|
|
29
|
+
export { type RiddleProofPublicCheckpointSummary, type RiddleProofPublicPolicyState, type RiddleProofPublicStateSummary, summarizeRiddleProofPublicState };
|
package/dist/spec/index.cjs
CHANGED
|
@@ -67,7 +67,8 @@ __export(spec_exports, {
|
|
|
67
67
|
recordValue: () => recordValue,
|
|
68
68
|
setRunStatus: () => setRunStatus,
|
|
69
69
|
shipControlStateFor: () => shipControlStateFor,
|
|
70
|
-
statePathsForRunState: () => statePathsForRunState
|
|
70
|
+
statePathsForRunState: () => statePathsForRunState,
|
|
71
|
+
summarizeRiddleProofPublicState: () => summarizeRiddleProofPublicState
|
|
71
72
|
});
|
|
72
73
|
module.exports = __toCommonJS(spec_exports);
|
|
73
74
|
|
|
@@ -1607,6 +1608,158 @@ function applyPrLifecycleState(state, input, at = timestamp2()) {
|
|
|
1607
1608
|
state.updated_at = at;
|
|
1608
1609
|
return state;
|
|
1609
1610
|
}
|
|
1611
|
+
|
|
1612
|
+
// src/public-state.ts
|
|
1613
|
+
function asRecord(value) {
|
|
1614
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
1615
|
+
}
|
|
1616
|
+
function stringValue(value) {
|
|
1617
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
1618
|
+
}
|
|
1619
|
+
function booleanValue(value) {
|
|
1620
|
+
return typeof value === "boolean" ? value : void 0;
|
|
1621
|
+
}
|
|
1622
|
+
function numberValue(value) {
|
|
1623
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
1624
|
+
}
|
|
1625
|
+
function firstStringValue(...values) {
|
|
1626
|
+
for (const value of values) {
|
|
1627
|
+
const text = stringValue(value);
|
|
1628
|
+
if (text) return text;
|
|
1629
|
+
}
|
|
1630
|
+
return void 0;
|
|
1631
|
+
}
|
|
1632
|
+
function firstBooleanValue(...values) {
|
|
1633
|
+
for (const value of values) {
|
|
1634
|
+
const bool = booleanValue(value);
|
|
1635
|
+
if (typeof bool === "boolean") return bool;
|
|
1636
|
+
}
|
|
1637
|
+
return void 0;
|
|
1638
|
+
}
|
|
1639
|
+
function firstRecordValue(...values) {
|
|
1640
|
+
for (const value of values) {
|
|
1641
|
+
const record = asRecord(value);
|
|
1642
|
+
if (Object.keys(record).length) return record;
|
|
1643
|
+
}
|
|
1644
|
+
return void 0;
|
|
1645
|
+
}
|
|
1646
|
+
function countValue(value) {
|
|
1647
|
+
const number = numberValue(value);
|
|
1648
|
+
return typeof number === "number" && number > 0 ? Math.trunc(number) : 0;
|
|
1649
|
+
}
|
|
1650
|
+
function checkpointSummaryFrom(...values) {
|
|
1651
|
+
const record = firstRecordValue(...values);
|
|
1652
|
+
if (!record) return void 0;
|
|
1653
|
+
const accepted = countValue(record.response_count);
|
|
1654
|
+
const rejected = countValue(record.rejected_response_count);
|
|
1655
|
+
const ignored = countValue(record.ignored_response_count);
|
|
1656
|
+
const duplicate = countValue(record.duplicate_response_count);
|
|
1657
|
+
const summary = {
|
|
1658
|
+
pending: booleanValue(record.pending),
|
|
1659
|
+
accepted_response_count: accepted,
|
|
1660
|
+
rejected_response_count: rejected,
|
|
1661
|
+
ignored_response_count: ignored,
|
|
1662
|
+
duplicate_response_count: duplicate,
|
|
1663
|
+
latest_decision: stringValue(record.latest_decision),
|
|
1664
|
+
audit_disclosure_required: rejected > 0 || ignored > 0 || duplicate > 0
|
|
1665
|
+
};
|
|
1666
|
+
return Object.values(summary).some((value) => typeof value !== "undefined") ? summary : void 0;
|
|
1667
|
+
}
|
|
1668
|
+
function uniqueStrings(values) {
|
|
1669
|
+
return [...new Set(values.filter(Boolean))];
|
|
1670
|
+
}
|
|
1671
|
+
function summarizeRiddleProofPublicState(input) {
|
|
1672
|
+
const record = asRecord(input);
|
|
1673
|
+
const runCard = asRecord(record.run_card);
|
|
1674
|
+
const stopCondition = asRecord(runCard.stop_condition);
|
|
1675
|
+
const raw = asRecord(record.raw);
|
|
1676
|
+
const request = asRecord(record.request);
|
|
1677
|
+
const requestMetadata = asRecord(record.request_metadata);
|
|
1678
|
+
const prState = asRecord(record.pr_state);
|
|
1679
|
+
const handoff = asRecord(record.pr_handoff_policy);
|
|
1680
|
+
const handoffState = stringValue(handoff.state);
|
|
1681
|
+
const status = firstStringValue(record.status, stopCondition.status);
|
|
1682
|
+
const ok = booleanValue(record.ok) ?? null;
|
|
1683
|
+
const shipMode = firstStringValue(request.ship_mode, requestMetadata.ship_mode, record.ship_mode, handoff.ship_mode);
|
|
1684
|
+
const explicitShippingDisabled = firstBooleanValue(
|
|
1685
|
+
record.shipping_disabled,
|
|
1686
|
+
stopCondition.shipping_disabled,
|
|
1687
|
+
raw.shipping_disabled,
|
|
1688
|
+
handoff.shipping_disabled
|
|
1689
|
+
);
|
|
1690
|
+
const shippingDisabled = explicitShippingDisabled === true || shipMode === "none" || handoffState === "proof_complete_ship_disabled";
|
|
1691
|
+
const explicitShipAuthorized = firstBooleanValue(
|
|
1692
|
+
record.ship_authorized,
|
|
1693
|
+
stopCondition.ship_authorized,
|
|
1694
|
+
raw.ship_authorized
|
|
1695
|
+
);
|
|
1696
|
+
const authorizationEvidence = Boolean(
|
|
1697
|
+
status === "shipped" || record.marked_ready === true || stringValue(prState.status) === "merged" || record.merge_commit || record.merged_at
|
|
1698
|
+
);
|
|
1699
|
+
const shipAuthorizedBeforeHold = explicitShipAuthorized ?? authorizationEvidence;
|
|
1700
|
+
const explicitShipHeld = firstBooleanValue(record.ship_held, stopCondition.ship_held, raw.ship_held);
|
|
1701
|
+
const inferredHeld = status === "ready_to_ship" && shippingDisabled && !shipAuthorizedBeforeHold;
|
|
1702
|
+
const shipHeld = explicitShipHeld === true || inferredHeld;
|
|
1703
|
+
const shipAuthorized = shipHeld ? false : shipAuthorizedBeforeHold === true;
|
|
1704
|
+
const proofComplete = Boolean(
|
|
1705
|
+
status === "ready_to_ship" || status === "shipped" || status === "completed" || status === "passed" || ok === true || handoff.proof_complete === true
|
|
1706
|
+
);
|
|
1707
|
+
const checkpointSummary = checkpointSummaryFrom(
|
|
1708
|
+
record.checkpoint_summary,
|
|
1709
|
+
stopCondition.checkpoint_summary,
|
|
1710
|
+
asRecord(record.details).checkpoint_summary,
|
|
1711
|
+
asRecord(raw.details).checkpoint_summary
|
|
1712
|
+
);
|
|
1713
|
+
const blockedOrWaiting = status === "blocked" || status === "failed" || status === "awaiting_checkpoint" || handoffState === "proof_blocked" || handoffState === "proof_review_required" || handoffState === "proof_failed" || handoffState === "proof_checkpoint_required";
|
|
1714
|
+
const proofPassed = Boolean(proofComplete && !blockedOrWaiting);
|
|
1715
|
+
const explicitMergeReady = firstBooleanValue(record.merge_ready, stopCondition.merge_ready, raw.merge_ready, handoff.merge_ready);
|
|
1716
|
+
const normalPrAllowed = firstBooleanValue(record.normal_pr_allowed, raw.normal_pr_allowed, handoff.normal_pr_allowed);
|
|
1717
|
+
const baseHandoffAllowed = !blockedOrWaiting && !shipHeld && !shippingDisabled;
|
|
1718
|
+
const mergeReady = baseHandoffAllowed && normalPrAllowed !== false && (explicitMergeReady ?? shipAuthorized);
|
|
1719
|
+
const syncAllowed = mergeReady;
|
|
1720
|
+
let policyState = "unknown";
|
|
1721
|
+
if (status === "awaiting_checkpoint" || handoffState === "proof_checkpoint_required") policyState = "awaiting_checkpoint";
|
|
1722
|
+
else if (status === "failed" || handoffState === "proof_failed") policyState = "proof_failed";
|
|
1723
|
+
else if (status === "blocked" || handoffState === "proof_blocked" || handoffState === "proof_review_required") policyState = "proof_blocked";
|
|
1724
|
+
else if (handoffState === "proof_complete_ship_disabled") policyState = "proof_complete_ship_disabled";
|
|
1725
|
+
else if (proofComplete && shipHeld && !shipAuthorized) policyState = "proof_passed_ship_held";
|
|
1726
|
+
else if (proofComplete && shippingDisabled && !shipAuthorized) policyState = "proof_complete_ship_disabled";
|
|
1727
|
+
else if (shipAuthorized) policyState = "ship_authorized";
|
|
1728
|
+
else if (proofPassed) policyState = "proof_passed";
|
|
1729
|
+
else if (status === "running") policyState = "proof_in_progress";
|
|
1730
|
+
const requiredDisclosures = [];
|
|
1731
|
+
if (shipHeld) requiredDisclosures.push("ship_held");
|
|
1732
|
+
if (shippingDisabled) requiredDisclosures.push("shipping_disabled");
|
|
1733
|
+
if (checkpointSummary?.audit_disclosure_required) requiredDisclosures.push("checkpoint_audit_counters");
|
|
1734
|
+
if (status === "awaiting_checkpoint" || handoffState === "proof_checkpoint_required") requiredDisclosures.push("checkpoint_required");
|
|
1735
|
+
const prohibitedClaims = [];
|
|
1736
|
+
if (!shipAuthorized || shipHeld || shippingDisabled) prohibitedClaims.push("ship_authorized", "shipped");
|
|
1737
|
+
if (!mergeReady) prohibitedClaims.push("merge_ready");
|
|
1738
|
+
if (!syncAllowed) prohibitedClaims.push("sync_allowed");
|
|
1739
|
+
if (blockedOrWaiting) {
|
|
1740
|
+
prohibitedClaims.push("proof_passed", "ready_to_ship");
|
|
1741
|
+
}
|
|
1742
|
+
if (checkpointSummary?.audit_disclosure_required) {
|
|
1743
|
+
prohibitedClaims.push("all_checkpoint_responses_accepted");
|
|
1744
|
+
}
|
|
1745
|
+
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";
|
|
1746
|
+
return {
|
|
1747
|
+
status,
|
|
1748
|
+
ok,
|
|
1749
|
+
policy_state: policyState,
|
|
1750
|
+
result_label: resultLabel,
|
|
1751
|
+
proof_complete: proofComplete,
|
|
1752
|
+
proof_passed: proofPassed,
|
|
1753
|
+
ship_held: shipHeld,
|
|
1754
|
+
shipping_disabled: shippingDisabled,
|
|
1755
|
+
ship_authorized: shipAuthorized,
|
|
1756
|
+
merge_ready: mergeReady,
|
|
1757
|
+
sync_allowed: syncAllowed,
|
|
1758
|
+
checkpoint_summary: checkpointSummary,
|
|
1759
|
+
required_disclosures: uniqueStrings(requiredDisclosures),
|
|
1760
|
+
prohibited_claims: uniqueStrings(prohibitedClaims)
|
|
1761
|
+
};
|
|
1762
|
+
}
|
|
1610
1763
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1611
1764
|
0 && (module.exports = {
|
|
1612
1765
|
RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION,
|
|
@@ -1646,5 +1799,6 @@ function applyPrLifecycleState(state, input, at = timestamp2()) {
|
|
|
1646
1799
|
recordValue,
|
|
1647
1800
|
setRunStatus,
|
|
1648
1801
|
shipControlStateFor,
|
|
1649
|
-
statePathsForRunState
|
|
1802
|
+
statePathsForRunState,
|
|
1803
|
+
summarizeRiddleProofPublicState
|
|
1650
1804
|
});
|
package/dist/spec/index.d.cts
CHANGED
|
@@ -3,3 +3,4 @@ export { RiddleProofShipControlState, TerminalMetadataInput, applyShipControlSta
|
|
|
3
3
|
export { CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, RunEventInput, appendRunEvent, appendStageHeartbeat, applyPrLifecycleState, createRunState, createRunStatusSnapshot, normalizeIntegrationContext, normalizePrLifecycleState, normalizeRunParams, setRunStatus } from '../state.cjs';
|
|
4
4
|
export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, buildCheckpointPacketForEngineResult, buildProofAssessmentCheckpointPacket, buildStageCheckpointPacket, checkpointPacketIdentity, checkpointResponseIdentity, checkpointSummaryFromState, createCheckpointResponseTemplate, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState } from '../checkpoint.cjs';
|
|
5
5
|
export { RIDDLE_PROOF_RUN_CARD_VERSION, createRiddleProofRunCard } from '../run-card.cjs';
|
|
6
|
+
export { RiddleProofPublicCheckpointSummary, RiddleProofPublicPolicyState, RiddleProofPublicStateSummary, summarizeRiddleProofPublicState } from '../public-state.cjs';
|
package/dist/spec/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { RiddleProofShipControlState, TerminalMetadataInput, applyShipControlSta
|
|
|
3
3
|
export { CreateRunStateInput, RIDDLE_PROOF_RUN_STATE_VERSION, RunEventInput, appendRunEvent, appendStageHeartbeat, applyPrLifecycleState, createRunState, createRunStatusSnapshot, normalizeIntegrationContext, normalizePrLifecycleState, normalizeRunParams, setRunStatus } from '../state.js';
|
|
4
4
|
export { RIDDLE_PROOF_CHECKPOINT_PACKET_VERSION, RIDDLE_PROOF_CHECKPOINT_RESPONSE_VERSION, authorPacketPayloadFromCheckpointResponse, buildAuthorCheckpointPacket, buildCheckpointPacketForEngineResult, buildProofAssessmentCheckpointPacket, buildStageCheckpointPacket, checkpointPacketIdentity, checkpointResponseIdentity, checkpointSummaryFromState, createCheckpointResponseTemplate, isDuplicateCheckpointResponse, normalizeCheckpointResponse, proofContractFromAuthorCheckpointResponse, statePathsForRunState } from '../checkpoint.js';
|
|
5
5
|
export { RIDDLE_PROOF_RUN_CARD_VERSION, createRiddleProofRunCard } from '../run-card.js';
|
|
6
|
+
export { RiddleProofPublicCheckpointSummary, RiddleProofPublicPolicyState, RiddleProofPublicStateSummary, summarizeRiddleProofPublicState } from '../public-state.js';
|
package/dist/spec/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import "../chunk-6F4PWJZI.js";
|
|
2
|
+
import {
|
|
3
|
+
summarizeRiddleProofPublicState
|
|
4
|
+
} from "../chunk-KG64Y5MC.js";
|
|
2
5
|
import {
|
|
3
6
|
RIDDLE_PROOF_RUN_STATE_VERSION,
|
|
4
7
|
appendRunEvent,
|
|
@@ -84,5 +87,6 @@ export {
|
|
|
84
87
|
recordValue,
|
|
85
88
|
setRunStatus,
|
|
86
89
|
shipControlStateFor,
|
|
87
|
-
statePathsForRunState
|
|
90
|
+
statePathsForRunState,
|
|
91
|
+
summarizeRiddleProofPublicState
|
|
88
92
|
};
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/spec/public-state.ts
|
|
21
|
+
var public_state_exports = {};
|
|
22
|
+
__export(public_state_exports, {
|
|
23
|
+
summarizeRiddleProofPublicState: () => summarizeRiddleProofPublicState
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(public_state_exports);
|
|
26
|
+
|
|
27
|
+
// src/public-state.ts
|
|
28
|
+
function asRecord(value) {
|
|
29
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
30
|
+
}
|
|
31
|
+
function stringValue(value) {
|
|
32
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
33
|
+
}
|
|
34
|
+
function booleanValue(value) {
|
|
35
|
+
return typeof value === "boolean" ? value : void 0;
|
|
36
|
+
}
|
|
37
|
+
function numberValue(value) {
|
|
38
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
39
|
+
}
|
|
40
|
+
function firstStringValue(...values) {
|
|
41
|
+
for (const value of values) {
|
|
42
|
+
const text = stringValue(value);
|
|
43
|
+
if (text) return text;
|
|
44
|
+
}
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
|
47
|
+
function firstBooleanValue(...values) {
|
|
48
|
+
for (const value of values) {
|
|
49
|
+
const bool = booleanValue(value);
|
|
50
|
+
if (typeof bool === "boolean") return bool;
|
|
51
|
+
}
|
|
52
|
+
return void 0;
|
|
53
|
+
}
|
|
54
|
+
function firstRecordValue(...values) {
|
|
55
|
+
for (const value of values) {
|
|
56
|
+
const record = asRecord(value);
|
|
57
|
+
if (Object.keys(record).length) return record;
|
|
58
|
+
}
|
|
59
|
+
return void 0;
|
|
60
|
+
}
|
|
61
|
+
function countValue(value) {
|
|
62
|
+
const number = numberValue(value);
|
|
63
|
+
return typeof number === "number" && number > 0 ? Math.trunc(number) : 0;
|
|
64
|
+
}
|
|
65
|
+
function checkpointSummaryFrom(...values) {
|
|
66
|
+
const record = firstRecordValue(...values);
|
|
67
|
+
if (!record) return void 0;
|
|
68
|
+
const accepted = countValue(record.response_count);
|
|
69
|
+
const rejected = countValue(record.rejected_response_count);
|
|
70
|
+
const ignored = countValue(record.ignored_response_count);
|
|
71
|
+
const duplicate = countValue(record.duplicate_response_count);
|
|
72
|
+
const summary = {
|
|
73
|
+
pending: booleanValue(record.pending),
|
|
74
|
+
accepted_response_count: accepted,
|
|
75
|
+
rejected_response_count: rejected,
|
|
76
|
+
ignored_response_count: ignored,
|
|
77
|
+
duplicate_response_count: duplicate,
|
|
78
|
+
latest_decision: stringValue(record.latest_decision),
|
|
79
|
+
audit_disclosure_required: rejected > 0 || ignored > 0 || duplicate > 0
|
|
80
|
+
};
|
|
81
|
+
return Object.values(summary).some((value) => typeof value !== "undefined") ? summary : void 0;
|
|
82
|
+
}
|
|
83
|
+
function uniqueStrings(values) {
|
|
84
|
+
return [...new Set(values.filter(Boolean))];
|
|
85
|
+
}
|
|
86
|
+
function summarizeRiddleProofPublicState(input) {
|
|
87
|
+
const record = asRecord(input);
|
|
88
|
+
const runCard = asRecord(record.run_card);
|
|
89
|
+
const stopCondition = asRecord(runCard.stop_condition);
|
|
90
|
+
const raw = asRecord(record.raw);
|
|
91
|
+
const request = asRecord(record.request);
|
|
92
|
+
const requestMetadata = asRecord(record.request_metadata);
|
|
93
|
+
const prState = asRecord(record.pr_state);
|
|
94
|
+
const handoff = asRecord(record.pr_handoff_policy);
|
|
95
|
+
const handoffState = stringValue(handoff.state);
|
|
96
|
+
const status = firstStringValue(record.status, stopCondition.status);
|
|
97
|
+
const ok = booleanValue(record.ok) ?? null;
|
|
98
|
+
const shipMode = firstStringValue(request.ship_mode, requestMetadata.ship_mode, record.ship_mode, handoff.ship_mode);
|
|
99
|
+
const explicitShippingDisabled = firstBooleanValue(
|
|
100
|
+
record.shipping_disabled,
|
|
101
|
+
stopCondition.shipping_disabled,
|
|
102
|
+
raw.shipping_disabled,
|
|
103
|
+
handoff.shipping_disabled
|
|
104
|
+
);
|
|
105
|
+
const shippingDisabled = explicitShippingDisabled === true || shipMode === "none" || handoffState === "proof_complete_ship_disabled";
|
|
106
|
+
const explicitShipAuthorized = firstBooleanValue(
|
|
107
|
+
record.ship_authorized,
|
|
108
|
+
stopCondition.ship_authorized,
|
|
109
|
+
raw.ship_authorized
|
|
110
|
+
);
|
|
111
|
+
const authorizationEvidence = Boolean(
|
|
112
|
+
status === "shipped" || record.marked_ready === true || stringValue(prState.status) === "merged" || record.merge_commit || record.merged_at
|
|
113
|
+
);
|
|
114
|
+
const shipAuthorizedBeforeHold = explicitShipAuthorized ?? authorizationEvidence;
|
|
115
|
+
const explicitShipHeld = firstBooleanValue(record.ship_held, stopCondition.ship_held, raw.ship_held);
|
|
116
|
+
const inferredHeld = status === "ready_to_ship" && shippingDisabled && !shipAuthorizedBeforeHold;
|
|
117
|
+
const shipHeld = explicitShipHeld === true || inferredHeld;
|
|
118
|
+
const shipAuthorized = shipHeld ? false : shipAuthorizedBeforeHold === true;
|
|
119
|
+
const proofComplete = Boolean(
|
|
120
|
+
status === "ready_to_ship" || status === "shipped" || status === "completed" || status === "passed" || ok === true || handoff.proof_complete === true
|
|
121
|
+
);
|
|
122
|
+
const checkpointSummary = checkpointSummaryFrom(
|
|
123
|
+
record.checkpoint_summary,
|
|
124
|
+
stopCondition.checkpoint_summary,
|
|
125
|
+
asRecord(record.details).checkpoint_summary,
|
|
126
|
+
asRecord(raw.details).checkpoint_summary
|
|
127
|
+
);
|
|
128
|
+
const blockedOrWaiting = status === "blocked" || status === "failed" || status === "awaiting_checkpoint" || handoffState === "proof_blocked" || handoffState === "proof_review_required" || handoffState === "proof_failed" || handoffState === "proof_checkpoint_required";
|
|
129
|
+
const proofPassed = Boolean(proofComplete && !blockedOrWaiting);
|
|
130
|
+
const explicitMergeReady = firstBooleanValue(record.merge_ready, stopCondition.merge_ready, raw.merge_ready, handoff.merge_ready);
|
|
131
|
+
const normalPrAllowed = firstBooleanValue(record.normal_pr_allowed, raw.normal_pr_allowed, handoff.normal_pr_allowed);
|
|
132
|
+
const baseHandoffAllowed = !blockedOrWaiting && !shipHeld && !shippingDisabled;
|
|
133
|
+
const mergeReady = baseHandoffAllowed && normalPrAllowed !== false && (explicitMergeReady ?? shipAuthorized);
|
|
134
|
+
const syncAllowed = mergeReady;
|
|
135
|
+
let policyState = "unknown";
|
|
136
|
+
if (status === "awaiting_checkpoint" || handoffState === "proof_checkpoint_required") policyState = "awaiting_checkpoint";
|
|
137
|
+
else if (status === "failed" || handoffState === "proof_failed") policyState = "proof_failed";
|
|
138
|
+
else if (status === "blocked" || handoffState === "proof_blocked" || handoffState === "proof_review_required") policyState = "proof_blocked";
|
|
139
|
+
else if (handoffState === "proof_complete_ship_disabled") policyState = "proof_complete_ship_disabled";
|
|
140
|
+
else if (proofComplete && shipHeld && !shipAuthorized) policyState = "proof_passed_ship_held";
|
|
141
|
+
else if (proofComplete && shippingDisabled && !shipAuthorized) policyState = "proof_complete_ship_disabled";
|
|
142
|
+
else if (shipAuthorized) policyState = "ship_authorized";
|
|
143
|
+
else if (proofPassed) policyState = "proof_passed";
|
|
144
|
+
else if (status === "running") policyState = "proof_in_progress";
|
|
145
|
+
const requiredDisclosures = [];
|
|
146
|
+
if (shipHeld) requiredDisclosures.push("ship_held");
|
|
147
|
+
if (shippingDisabled) requiredDisclosures.push("shipping_disabled");
|
|
148
|
+
if (checkpointSummary?.audit_disclosure_required) requiredDisclosures.push("checkpoint_audit_counters");
|
|
149
|
+
if (status === "awaiting_checkpoint" || handoffState === "proof_checkpoint_required") requiredDisclosures.push("checkpoint_required");
|
|
150
|
+
const prohibitedClaims = [];
|
|
151
|
+
if (!shipAuthorized || shipHeld || shippingDisabled) prohibitedClaims.push("ship_authorized", "shipped");
|
|
152
|
+
if (!mergeReady) prohibitedClaims.push("merge_ready");
|
|
153
|
+
if (!syncAllowed) prohibitedClaims.push("sync_allowed");
|
|
154
|
+
if (blockedOrWaiting) {
|
|
155
|
+
prohibitedClaims.push("proof_passed", "ready_to_ship");
|
|
156
|
+
}
|
|
157
|
+
if (checkpointSummary?.audit_disclosure_required) {
|
|
158
|
+
prohibitedClaims.push("all_checkpoint_responses_accepted");
|
|
159
|
+
}
|
|
160
|
+
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";
|
|
161
|
+
return {
|
|
162
|
+
status,
|
|
163
|
+
ok,
|
|
164
|
+
policy_state: policyState,
|
|
165
|
+
result_label: resultLabel,
|
|
166
|
+
proof_complete: proofComplete,
|
|
167
|
+
proof_passed: proofPassed,
|
|
168
|
+
ship_held: shipHeld,
|
|
169
|
+
shipping_disabled: shippingDisabled,
|
|
170
|
+
ship_authorized: shipAuthorized,
|
|
171
|
+
merge_ready: mergeReady,
|
|
172
|
+
sync_allowed: syncAllowed,
|
|
173
|
+
checkpoint_summary: checkpointSummary,
|
|
174
|
+
required_disclosures: uniqueStrings(requiredDisclosures),
|
|
175
|
+
prohibited_claims: uniqueStrings(prohibitedClaims)
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
179
|
+
0 && (module.exports = {
|
|
180
|
+
summarizeRiddleProofPublicState
|
|
181
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RiddleProofPublicCheckpointSummary, RiddleProofPublicPolicyState, RiddleProofPublicStateSummary, summarizeRiddleProofPublicState } from '../public-state.cjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RiddleProofPublicCheckpointSummary, RiddleProofPublicPolicyState, RiddleProofPublicStateSummary, summarizeRiddleProofPublicState } from '../public-state.js';
|