@riddledc/riddle-proof 0.5.57 → 0.7.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/README.md +91 -0
- package/dist/basic-gameplay.cjs +437 -4
- package/dist/basic-gameplay.d.cts +121 -2
- package/dist/basic-gameplay.d.ts +121 -2
- package/dist/basic-gameplay.js +23 -3
- package/dist/chunk-7NMAU4DP.js +808 -0
- package/dist/chunk-AAIASO2C.js +699 -0
- package/dist/cli.cjs +950 -0
- package/dist/cli.js +192 -3
- package/dist/engine-harness.js +2 -2
- package/dist/index.cjs +1258 -2
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +60 -4
- package/dist/profile.cjs +848 -0
- package/dist/profile.d.cts +175 -0
- package/dist/profile.d.ts +175 -0
- package/dist/profile.js +38 -0
- package/examples/profiles/page-content-basic.json +26 -0
- package/package.json +8 -2
- package/dist/chunk-53DJMNQ6.js +0 -276
- package/dist/{chunk-2FBF2UDZ.js → chunk-D3M2FAYQ.js} +3 -3
package/dist/chunk-53DJMNQ6.js
DELETED
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
// src/basic-gameplay.ts
|
|
2
|
-
var RIDDLE_PROOF_BASIC_GAMEPLAY_VERSION = "riddle-proof.basic-gameplay.v1";
|
|
3
|
-
var RIDDLE_PROOF_BASIC_GAMEPLAY_ASSESSMENT_VERSION = "riddle-proof.basic-gameplay.assessment.v1";
|
|
4
|
-
var RIDDLE_PROOF_BASIC_GAMEPLAY_CATCH_VERSION = "riddle-proof.basic-gameplay.catch.v1";
|
|
5
|
-
var BASIC_GAMEPLAY_CONTAINER_KEYS = [
|
|
6
|
-
"basic_gameplay",
|
|
7
|
-
"basicGameplay",
|
|
8
|
-
"basic_gameplay_evidence",
|
|
9
|
-
"basicGameplayEvidence",
|
|
10
|
-
"gameplay_proof",
|
|
11
|
-
"gameplayProof"
|
|
12
|
-
];
|
|
13
|
-
function assessBasicGameplayEvidence(evidence, options = {}) {
|
|
14
|
-
const run = extractBasicGameplayEvidence(evidence);
|
|
15
|
-
if (!run) {
|
|
16
|
-
return {
|
|
17
|
-
version: RIDDLE_PROOF_BASIC_GAMEPLAY_ASSESSMENT_VERSION,
|
|
18
|
-
evidence_present: false,
|
|
19
|
-
passed: false,
|
|
20
|
-
checked_routes: 0,
|
|
21
|
-
passing_routes: 0,
|
|
22
|
-
failing_routes: [],
|
|
23
|
-
failure_counts: {},
|
|
24
|
-
warning_counts: {},
|
|
25
|
-
route_results: []
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
const routeResults = (run.results || []).map((route) => assessBasicGameplayRoute(route, options));
|
|
29
|
-
const failingRoutes = routeResults.filter((result) => !result.ok).map((result) => ({
|
|
30
|
-
name: result.name,
|
|
31
|
-
path: result.path,
|
|
32
|
-
failures: result.failures,
|
|
33
|
-
warnings: result.warnings
|
|
34
|
-
}));
|
|
35
|
-
return {
|
|
36
|
-
version: RIDDLE_PROOF_BASIC_GAMEPLAY_ASSESSMENT_VERSION,
|
|
37
|
-
evidence_present: true,
|
|
38
|
-
passed: failingRoutes.length === 0,
|
|
39
|
-
checked_routes: routeResults.length,
|
|
40
|
-
passing_routes: routeResults.filter((result) => result.ok).length,
|
|
41
|
-
failing_routes: failingRoutes,
|
|
42
|
-
failure_counts: countCodes(routeResults.flatMap((result) => result.failures)),
|
|
43
|
-
warning_counts: countCodes(routeResults.flatMap((result) => result.warnings)),
|
|
44
|
-
route_results: routeResults
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
function assessBasicGameplayRoute(route, options = {}) {
|
|
48
|
-
const maxMobileOverflowPx = options.maxMobileOverflowPx ?? 4;
|
|
49
|
-
const minBodyTextLength = options.minBodyTextLength ?? 20;
|
|
50
|
-
const minVisibleLargeNodes = options.minVisibleLargeNodes ?? 3;
|
|
51
|
-
const minSurfaceLargeNodes = options.minSurfaceLargeNodes ?? 8;
|
|
52
|
-
const warnOnMissingResetPath = options.warnOnMissingResetPath ?? true;
|
|
53
|
-
const warnOnConsoleError = options.warnOnConsoleError ?? true;
|
|
54
|
-
const failOnConsoleError = options.failOnConsoleError ?? false;
|
|
55
|
-
const failures = [];
|
|
56
|
-
const warnings = [];
|
|
57
|
-
const initial = route.initial || {};
|
|
58
|
-
const timed = route.timed || {};
|
|
59
|
-
const afterAction = route.after_action || route.afterAction || {};
|
|
60
|
-
const mobile = route.mobile || {};
|
|
61
|
-
const timedChange = changed(initial, timed);
|
|
62
|
-
const actionChange = changed(timed, afterAction);
|
|
63
|
-
const surfaceVisible = numberValue(initial.visible_canvas_count) > 0 || numberValue(initial.enabled_clickable_count) > 0 || numberValue(initial.visible_large_node_count) >= minSurfaceLargeNodes;
|
|
64
|
-
const actionResults = listValue(route.action_results || route.actionResults);
|
|
65
|
-
const actionAttempted = actionResults.some((result) => result.ok === true && result.action !== "wait");
|
|
66
|
-
const actionFailed = actionResults.some((result) => result.ok === false && result.action !== "wait");
|
|
67
|
-
const stateChangeObserved = actionChange.changed || timedChange.changed;
|
|
68
|
-
const resetPathPresent = numberValue(initial.reset_control_count) > 0 || numberValue(timed.reset_control_count) > 0 || numberValue(afterAction.reset_control_count) > 0;
|
|
69
|
-
const responseStatus = firstNumber(route.http_status, route.response_status, route.status);
|
|
70
|
-
const pageErrorCount = numberValue(route.page_error_count);
|
|
71
|
-
const consoleErrorCount = numberValue(route.console_error_count);
|
|
72
|
-
const mobileOverflowPx = numberValue(mobile.overflow_px);
|
|
73
|
-
if (responseStatus !== null && responseStatus >= 400) failures.push("route_http_error");
|
|
74
|
-
if (pageErrorCount > 0) failures.push("fatal_page_error");
|
|
75
|
-
if (numberValue(initial.body_text_length) < minBodyTextLength && numberValue(initial.visible_large_node_count) < minVisibleLargeNodes) {
|
|
76
|
-
failures.push("route_blank_or_thin");
|
|
77
|
-
}
|
|
78
|
-
if (!surfaceVisible) failures.push("no_game_surface");
|
|
79
|
-
if (mobileOverflowPx > maxMobileOverflowPx) failures.push("mobile_horizontal_overflow");
|
|
80
|
-
if (!actionAttempted && !timedChange.changed) failures.push("primary_control_missing");
|
|
81
|
-
if (actionAttempted && !stateChangeObserved) failures.push("primary_control_inert");
|
|
82
|
-
if (failOnConsoleError && consoleErrorCount > 0) failures.push("fatal_page_error");
|
|
83
|
-
if (numberValue(initial.visible_canvas_count) > 0 && actionAttempted && !timedChange.canvas_changed && !actionChange.canvas_changed && !actionChange.screenshot_changed) {
|
|
84
|
-
warnings.push("canvas_inert");
|
|
85
|
-
}
|
|
86
|
-
if (actionFailed) warnings.push("some_actions_failed");
|
|
87
|
-
if (warnOnMissingResetPath && !resetPathPresent && route.requires_reset !== false && actionAttempted && stateChangeObserved) {
|
|
88
|
-
warnings.push("missing_reset_path");
|
|
89
|
-
}
|
|
90
|
-
if (warnOnConsoleError && consoleErrorCount > 0) warnings.push("critical_console_error");
|
|
91
|
-
return {
|
|
92
|
-
name: route.name,
|
|
93
|
-
path: route.path,
|
|
94
|
-
ok: failures.length === 0,
|
|
95
|
-
failures,
|
|
96
|
-
warnings,
|
|
97
|
-
signals: {
|
|
98
|
-
route_loaded: !failures.includes("route_http_error") && !failures.includes("route_blank_or_thin"),
|
|
99
|
-
surface_visible: surfaceVisible,
|
|
100
|
-
action_attempted: actionAttempted,
|
|
101
|
-
timed_progression_observed: timedChange.changed,
|
|
102
|
-
first_interaction_observed: actionChange.changed,
|
|
103
|
-
state_change_observed: stateChangeObserved,
|
|
104
|
-
mobile_overflow_absent: mobileOverflowPx <= maxMobileOverflowPx,
|
|
105
|
-
reset_path_present: resetPathPresent,
|
|
106
|
-
fatal_errors_absent: pageErrorCount === 0
|
|
107
|
-
},
|
|
108
|
-
diffs: {
|
|
109
|
-
timed: timedChange,
|
|
110
|
-
after_action: actionChange
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
function createBasicGameplayCatchSummary(input, options = {}) {
|
|
115
|
-
const before = summarizeAssessment(assessBasicGameplayEvidence(input.before, options));
|
|
116
|
-
const after = input.after === void 0 ? void 0 : summarizeAssessment(assessBasicGameplayEvidence(input.after, options));
|
|
117
|
-
const fixed = Boolean(after && before.notable_codes.length > 0 && after.passed && after.notable_codes.length === 0);
|
|
118
|
-
const title = input.title || [
|
|
119
|
-
input.site || "Basic gameplay",
|
|
120
|
-
input.route ? `${input.route} proof catch` : "proof catch"
|
|
121
|
-
].join(" ");
|
|
122
|
-
const beforeCodes = before.notable_codes.length ? before.notable_codes.join(", ") : "no failing or warning codes";
|
|
123
|
-
const afterCodes = after ? after.notable_codes.length ? after.notable_codes.join(", ") : "no failing or warning codes" : "not verified";
|
|
124
|
-
const summaryLines = [
|
|
125
|
-
`Before: ${before.checked_routes} checked, ${before.passing_routes} passing, codes: ${beforeCodes}.`,
|
|
126
|
-
after ? `After: ${after.checked_routes} checked, ${after.passing_routes} passing, codes: ${afterCodes}.` : "After: not provided."
|
|
127
|
-
];
|
|
128
|
-
if (input.fix?.summary) summaryLines.push(`Fix: ${input.fix.summary}`);
|
|
129
|
-
if (input.artifacts?.length) summaryLines.push(`Artifacts: ${input.artifacts.length} attached.`);
|
|
130
|
-
return {
|
|
131
|
-
version: RIDDLE_PROOF_BASIC_GAMEPLAY_CATCH_VERSION,
|
|
132
|
-
title,
|
|
133
|
-
site: input.site,
|
|
134
|
-
route: input.route,
|
|
135
|
-
detected_at: input.detected_at || (/* @__PURE__ */ new Date()).toISOString(),
|
|
136
|
-
before,
|
|
137
|
-
after,
|
|
138
|
-
fixed,
|
|
139
|
-
fix: input.fix,
|
|
140
|
-
artifacts: input.artifacts || [],
|
|
141
|
-
summary_lines: summaryLines,
|
|
142
|
-
marketing_summary: fixed ? `${title}: Riddle Proof caught ${beforeCodes}; after the fix, ${afterCodes}.` : `${title}: Riddle Proof caught ${beforeCodes}; after evidence is ${after ? "not yet clean" : "not yet attached"}.`
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
function extractBasicGameplayEvidence(...sources) {
|
|
146
|
-
const seen = /* @__PURE__ */ new Set();
|
|
147
|
-
for (const source of sources) {
|
|
148
|
-
const found = findBasicGameplayEvidence(source, seen);
|
|
149
|
-
if (found) return found;
|
|
150
|
-
}
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
function summarizeAssessment(assessment) {
|
|
154
|
-
return {
|
|
155
|
-
evidence_present: assessment.evidence_present,
|
|
156
|
-
passed: assessment.passed,
|
|
157
|
-
checked_routes: assessment.checked_routes,
|
|
158
|
-
passing_routes: assessment.passing_routes,
|
|
159
|
-
failing_routes: assessment.failing_routes,
|
|
160
|
-
failure_counts: assessment.failure_counts,
|
|
161
|
-
warning_counts: assessment.warning_counts,
|
|
162
|
-
notable_codes: [
|
|
163
|
-
...Object.keys(assessment.failure_counts),
|
|
164
|
-
...Object.keys(assessment.warning_counts)
|
|
165
|
-
].sort()
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
function findBasicGameplayEvidence(value, seen, depth = 0) {
|
|
169
|
-
if (depth > 6 || value === null || value === void 0) return null;
|
|
170
|
-
if (typeof value === "string") {
|
|
171
|
-
const parsed = parseJson(value);
|
|
172
|
-
return parsed === null ? null : findBasicGameplayEvidence(parsed, seen, depth + 1);
|
|
173
|
-
}
|
|
174
|
-
if (Array.isArray(value)) {
|
|
175
|
-
if (seen.has(value)) return null;
|
|
176
|
-
seen.add(value);
|
|
177
|
-
if (value.some((item) => hasRouteShape(recordValue(item)))) {
|
|
178
|
-
return { results: value.filter((item) => hasRouteShape(recordValue(item))) };
|
|
179
|
-
}
|
|
180
|
-
for (const item of value) {
|
|
181
|
-
const found = findBasicGameplayEvidence(item, seen, depth + 1);
|
|
182
|
-
if (found) return found;
|
|
183
|
-
}
|
|
184
|
-
return null;
|
|
185
|
-
}
|
|
186
|
-
const record = recordValue(value);
|
|
187
|
-
if (!record || seen.has(record)) return null;
|
|
188
|
-
seen.add(record);
|
|
189
|
-
if (record.version === RIDDLE_PROOF_BASIC_GAMEPLAY_VERSION || Array.isArray(record.results)) {
|
|
190
|
-
return {
|
|
191
|
-
...record,
|
|
192
|
-
results: listValue(record.results).filter((item) => Boolean(recordValue(item)))
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
if (hasRouteShape(record)) {
|
|
196
|
-
return { results: [record] };
|
|
197
|
-
}
|
|
198
|
-
for (const key of BASIC_GAMEPLAY_CONTAINER_KEYS) {
|
|
199
|
-
if (Object.prototype.hasOwnProperty.call(record, key)) {
|
|
200
|
-
const nested = findBasicGameplayEvidence(record[key], seen, depth + 1);
|
|
201
|
-
if (nested) return nested;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
for (const item of Object.values(record)) {
|
|
205
|
-
const found = findBasicGameplayEvidence(item, seen, depth + 1);
|
|
206
|
-
if (found) return found;
|
|
207
|
-
}
|
|
208
|
-
return null;
|
|
209
|
-
}
|
|
210
|
-
function hasRouteShape(record) {
|
|
211
|
-
return Boolean(record && (record.initial || record.after_action || record.afterAction || record.action_results || record.actionResults) && (record.path || record.name));
|
|
212
|
-
}
|
|
213
|
-
function changed(before, after) {
|
|
214
|
-
const bodyTextChanged = Boolean(before.body_text_hash && after.body_text_hash && before.body_text_hash !== after.body_text_hash);
|
|
215
|
-
const screenshotChanged = Boolean(before.screenshot_hash && after.screenshot_hash && before.screenshot_hash !== after.screenshot_hash);
|
|
216
|
-
const beforeCanvasHashes = canvasHashes(before.canvases);
|
|
217
|
-
const afterCanvasHashes = canvasHashes(after.canvases);
|
|
218
|
-
const canvasChanged = Boolean(beforeCanvasHashes && afterCanvasHashes && beforeCanvasHashes !== afterCanvasHashes);
|
|
219
|
-
return {
|
|
220
|
-
body_text_changed: bodyTextChanged,
|
|
221
|
-
screenshot_changed: screenshotChanged,
|
|
222
|
-
canvas_changed: canvasChanged,
|
|
223
|
-
changed: bodyTextChanged || screenshotChanged || canvasChanged
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
function canvasHashes(canvases) {
|
|
227
|
-
return (canvases || []).map((canvas) => canvas.hash).filter(Boolean).join("|");
|
|
228
|
-
}
|
|
229
|
-
function countCodes(codes) {
|
|
230
|
-
const counts = {};
|
|
231
|
-
for (const code of codes) counts[code] = (counts[code] || 0) + 1;
|
|
232
|
-
return counts;
|
|
233
|
-
}
|
|
234
|
-
function firstNumber(...values) {
|
|
235
|
-
for (const value of values) {
|
|
236
|
-
const number = numericValue(value);
|
|
237
|
-
if (number !== null) return number;
|
|
238
|
-
}
|
|
239
|
-
return null;
|
|
240
|
-
}
|
|
241
|
-
function numberValue(value) {
|
|
242
|
-
return numericValue(value) ?? 0;
|
|
243
|
-
}
|
|
244
|
-
function numericValue(value) {
|
|
245
|
-
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
246
|
-
if (typeof value === "string" && value.trim()) {
|
|
247
|
-
const parsed = Number(value);
|
|
248
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
249
|
-
}
|
|
250
|
-
return null;
|
|
251
|
-
}
|
|
252
|
-
function recordValue(value) {
|
|
253
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
254
|
-
}
|
|
255
|
-
function listValue(value) {
|
|
256
|
-
return Array.isArray(value) ? value : [];
|
|
257
|
-
}
|
|
258
|
-
function parseJson(value) {
|
|
259
|
-
const trimmed = value.trim();
|
|
260
|
-
if (!trimmed || !/^[{[]/.test(trimmed)) return null;
|
|
261
|
-
try {
|
|
262
|
-
return JSON.parse(trimmed);
|
|
263
|
-
} catch {
|
|
264
|
-
return null;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
export {
|
|
269
|
-
RIDDLE_PROOF_BASIC_GAMEPLAY_VERSION,
|
|
270
|
-
RIDDLE_PROOF_BASIC_GAMEPLAY_ASSESSMENT_VERSION,
|
|
271
|
-
RIDDLE_PROOF_BASIC_GAMEPLAY_CATCH_VERSION,
|
|
272
|
-
assessBasicGameplayEvidence,
|
|
273
|
-
assessBasicGameplayRoute,
|
|
274
|
-
createBasicGameplayCatchSummary,
|
|
275
|
-
extractBasicGameplayEvidence
|
|
276
|
-
};
|
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
normalizeRunParams,
|
|
7
7
|
setRunStatus
|
|
8
8
|
} from "./chunk-MO24D3PY.js";
|
|
9
|
+
import {
|
|
10
|
+
createRiddleProofRunCard
|
|
11
|
+
} from "./chunk-3UHWI3FO.js";
|
|
9
12
|
import {
|
|
10
13
|
visualDeltaForState,
|
|
11
14
|
visualDeltaRequiredForState,
|
|
12
15
|
visualDeltaShipGateReason
|
|
13
16
|
} from "./chunk-RFJ5BQF6.js";
|
|
14
|
-
import {
|
|
15
|
-
createRiddleProofRunCard
|
|
16
|
-
} from "./chunk-3UHWI3FO.js";
|
|
17
17
|
import {
|
|
18
18
|
authorPacketPayloadFromCheckpointResponse,
|
|
19
19
|
buildCheckpointPacketForEngineResult,
|