@threenative/runtime-native 0.2.0 → 0.3.1
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/NOTICE +2 -0
- package/README.md +63 -0
- package/android/README.md +2 -2
- package/android/app/build.gradle.kts +177 -30
- package/android/app/src/main/AndroidManifest.xml +8 -1
- package/android/app/src/main/java/com/mystral/engine/MystralActivity.java +190 -2
- package/android/app/src/main/java/com/mystral/engine/TnUiOverlay.java +261 -0
- package/android/app/src/main/res/values/branding.xml +12 -0
- package/android/app/src/main/res/values/themes.xml +2 -0
- package/android/gradle.properties +1 -1
- package/package.json +44 -8
- package/scripts/asset-preflight.mjs +442 -0
- package/scripts/bundle.mjs +178 -48
- package/scripts/check-source-list.mjs +90 -0
- package/scripts/device-preflight.mjs +456 -0
- package/scripts/install-prebuilt.mjs +326 -30
- package/scripts/package-android.mjs +414 -23
- package/scripts/package-desktop.mjs +132 -12
- package/scripts/package-ios.mjs +249 -25
- package/scripts/physical-device-evidence.mjs +644 -0
- package/scripts/production-evidence.mjs +101 -2
- package/scripts/profile-production.mjs +544 -115
- package/scripts/qualify-physical-mobile.mjs +1327 -0
- package/scripts/verify-starter-desktop.mjs +140 -16
- package/scripts/xvfb.sh +68 -0
|
@@ -0,0 +1,644 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
5
|
+
import { join, relative, sep } from "node:path";
|
|
6
|
+
|
|
7
|
+
export const PHYSICAL_EVIDENCE_SCHEMA = "physicalDeviceEvidenceV1";
|
|
8
|
+
export const REQUIRED_PREREQUISITES = ["prd053", "prd054", "prd046", "prd048"];
|
|
9
|
+
export const REQUIRED_GATE_IDS = [
|
|
10
|
+
"evidence-schema",
|
|
11
|
+
"android-physical-identity",
|
|
12
|
+
"ios-physical-identity",
|
|
13
|
+
"provenance-consistency",
|
|
14
|
+
"lifecycle-continuity",
|
|
15
|
+
"android-signed-install",
|
|
16
|
+
"ios-signed-install",
|
|
17
|
+
"multitouch-consumption",
|
|
18
|
+
"native-physics-consumption",
|
|
19
|
+
"telemetry-completeness",
|
|
20
|
+
"qualification-rollup",
|
|
21
|
+
"repository-collection",
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const ROOT_KEYS = new Set([
|
|
25
|
+
"schemaVersion",
|
|
26
|
+
"identity",
|
|
27
|
+
"source",
|
|
28
|
+
"device",
|
|
29
|
+
"signing",
|
|
30
|
+
"prerequisites",
|
|
31
|
+
"execution",
|
|
32
|
+
"lifecycle",
|
|
33
|
+
"consumption",
|
|
34
|
+
"telemetry",
|
|
35
|
+
"artifacts",
|
|
36
|
+
"gateEvidence",
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
const COMMIT_SHA = /^[0-9a-f]{7,64}$/iu;
|
|
40
|
+
const SHA256 = /^[0-9a-f]{64}$/u;
|
|
41
|
+
const ISO_UTC = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/u;
|
|
42
|
+
|
|
43
|
+
export class EvidenceValidationError extends Error {
|
|
44
|
+
constructor(errors) {
|
|
45
|
+
super(`Physical evidence validation failed: ${errors.join("; ")}`);
|
|
46
|
+
this.name = "EvidenceValidationError";
|
|
47
|
+
this.errors = errors;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function isRecord(value) {
|
|
52
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function add(errors, path, message) {
|
|
56
|
+
errors.push(`${path}: ${message}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function objectAt(value, path, errors, allowed) {
|
|
60
|
+
if (!isRecord(value)) {
|
|
61
|
+
add(errors, path, "must be an object");
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
for (const key of Object.keys(value)) {
|
|
65
|
+
if (!allowed.has(key)) add(errors, `${path}.${key}`, "unknown field");
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function required(value, path, errors) {
|
|
71
|
+
if (value === undefined) add(errors, path, "is required");
|
|
72
|
+
return value !== undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function stringAt(value, path, errors, { nonEmpty = true } = {}) {
|
|
76
|
+
if (typeof value !== "string" || (nonEmpty && value.length === 0)) {
|
|
77
|
+
add(errors, path, nonEmpty ? "must be a non-empty string" : "must be a string");
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function booleanAt(value, path, errors) {
|
|
84
|
+
if (typeof value !== "boolean") {
|
|
85
|
+
add(errors, path, "must be a boolean");
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function finiteNumberAt(value, path, errors, { integer = false, minimum } = {}) {
|
|
92
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
93
|
+
add(errors, path, "must be a finite number");
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
if (integer && !Number.isInteger(value)) add(errors, path, "must be an integer");
|
|
97
|
+
if (minimum !== undefined && value < minimum) add(errors, path, `must be >= ${minimum}`);
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function hashAt(value, path, errors) {
|
|
102
|
+
if (!stringAt(value, path, errors) || !SHA256.test(value)) {
|
|
103
|
+
if (typeof value === "string" && !SHA256.test(value)) add(errors, path, "must be a lowercase SHA-256 hex digest");
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function commitAt(value, path, errors) {
|
|
110
|
+
if (!stringAt(value, path, errors) || !COMMIT_SHA.test(value)) {
|
|
111
|
+
if (typeof value === "string" && !COMMIT_SHA.test(value)) add(errors, path, "must be a git SHA");
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function timestampAt(value, path, errors) {
|
|
118
|
+
if (!stringAt(value, path, errors) || !ISO_UTC.test(value) || !Number.isFinite(Date.parse(value))) {
|
|
119
|
+
if (typeof value === "string") add(errors, path, "must be an ISO-8601 UTC timestamp");
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function enumAt(value, path, errors, values) {
|
|
126
|
+
if (!values.includes(value)) {
|
|
127
|
+
add(errors, path, `must be one of ${values.join(", ")}`);
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function relativePathAt(value, path, errors) {
|
|
134
|
+
if (!stringAt(value, path, errors)) return false;
|
|
135
|
+
if (value.startsWith("/") || value.split("/").includes("..")) add(errors, path, "must be repository-relative");
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function validateIdentity(value, errors) {
|
|
140
|
+
const path = "identity";
|
|
141
|
+
if (!objectAt(value, path, errors, new Set(["schemaVersion", "runId", "startedAt", "endedAt", "verdict", "blockers", "evidenceClass"]))) return;
|
|
142
|
+
if (value.schemaVersion !== 1) add(errors, `${path}.schemaVersion`, "must equal 1");
|
|
143
|
+
stringAt(value.runId, `${path}.runId`, errors);
|
|
144
|
+
timestampAt(value.startedAt, `${path}.startedAt`, errors);
|
|
145
|
+
timestampAt(value.endedAt, `${path}.endedAt`, errors);
|
|
146
|
+
enumAt(value.verdict, `${path}.verdict`, errors, ["pass", "fail", "blocked"]);
|
|
147
|
+
if (!Array.isArray(value.blockers)) add(errors, `${path}.blockers`, "must be an array");
|
|
148
|
+
else value.blockers.forEach((item, index) => stringAt(item, `${path}.blockers[${index}]`, errors));
|
|
149
|
+
enumAt(value.evidenceClass, `${path}.evidenceClass`, errors, ["physical-device"]);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function validateSource(value, errors, options) {
|
|
153
|
+
const path = "source";
|
|
154
|
+
if (!objectAt(value, path, errors, new Set(["remote", "branch", "headSha", "worktree", "artifactSourceSha", "packageVersion", "artifactSha256", "releaseRun", "publishedPackage", "promotedConsumer"]))) return;
|
|
155
|
+
stringAt(value.remote, `${path}.remote`, errors);
|
|
156
|
+
stringAt(value.branch, `${path}.branch`, errors);
|
|
157
|
+
commitAt(value.headSha, `${path}.headSha`, errors);
|
|
158
|
+
enumAt(value.worktree, `${path}.worktree`, errors, ["clean", "dirty"]);
|
|
159
|
+
commitAt(value.artifactSourceSha, `${path}.artifactSourceSha`, errors);
|
|
160
|
+
stringAt(value.packageVersion, `${path}.packageVersion`, errors);
|
|
161
|
+
hashAt(value.artifactSha256, `${path}.artifactSha256`, errors);
|
|
162
|
+
for (const key of ["releaseRun", "publishedPackage", "promotedConsumer"]) {
|
|
163
|
+
if (value[key] !== null) stringAt(value[key], `${path}.${key}`, errors);
|
|
164
|
+
}
|
|
165
|
+
if (value.artifactSourceSha !== value.headSha) add(errors, `${path}.artifactSourceSha`, "must equal source.headSha");
|
|
166
|
+
if (options.candidateSha !== undefined && value.headSha !== options.candidateSha) add(errors, `${path}.headSha`, `must equal candidate SHA ${options.candidateSha}`);
|
|
167
|
+
if (options.artifactSha256 !== undefined && value.artifactSha256 !== options.artifactSha256) add(errors, `${path}.artifactSha256`, `must equal supplied artifact SHA ${options.artifactSha256}`);
|
|
168
|
+
if (value.worktree !== "clean") add(errors, `${path}.worktree`, "physical qualification requires a clean worktree");
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function validateDevice(value, errors, options) {
|
|
172
|
+
const path = "device";
|
|
173
|
+
if (!objectAt(value, path, errors, new Set(["platform", "kind", "identifierHash", "name", "manufacturer", "model", "osVersion", "osBuild", "cpuAbi", "gpu", "driver", "screenModes"]))) return;
|
|
174
|
+
enumAt(value.platform, `${path}.platform`, errors, ["android", "ios"]);
|
|
175
|
+
enumAt(value.kind, `${path}.kind`, errors, ["physical"]);
|
|
176
|
+
hashAt(value.identifierHash, `${path}.identifierHash`, errors);
|
|
177
|
+
if (options.platform !== undefined && value.platform !== options.platform) add(errors, `${path}.platform`, `must equal target ${options.platform}`);
|
|
178
|
+
if (options.identifierHash !== undefined && value.identifierHash !== options.identifierHash) add(errors, `${path}.identifierHash`, "does not match the supplied physical device");
|
|
179
|
+
for (const key of ["name", "manufacturer", "model", "osVersion", "osBuild", "cpuAbi", "gpu", "driver"]) stringAt(value[key], `${path}.${key}`, errors);
|
|
180
|
+
if (!Array.isArray(value.screenModes) || value.screenModes.length === 0) add(errors, `${path}.screenModes`, "must contain at least one mode");
|
|
181
|
+
else {
|
|
182
|
+
value.screenModes.forEach((mode, index) => {
|
|
183
|
+
const modePath = `${path}.screenModes[${index}]`;
|
|
184
|
+
if (!objectAt(mode, modePath, errors, new Set(["width", "height", "orientation"]))) return;
|
|
185
|
+
finiteNumberAt(mode.width, `${modePath}.width`, errors, { integer: true, minimum: 1 });
|
|
186
|
+
finiteNumberAt(mode.height, `${modePath}.height`, errors, { integer: true, minimum: 1 });
|
|
187
|
+
enumAt(mode.orientation, `${modePath}.orientation`, errors, ["portrait", "landscape"]);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function validateSigning(value, errors) {
|
|
193
|
+
const path = "signing";
|
|
194
|
+
if (!objectAt(value, path, errors, new Set(["verificationCommand", "signerId", "certificateFingerprint", "profileFingerprint", "expiresAt", "applicationId", "debuggable", "installResult"]))) return;
|
|
195
|
+
stringAt(value.verificationCommand, `${path}.verificationCommand`, errors);
|
|
196
|
+
stringAt(value.signerId, `${path}.signerId`, errors);
|
|
197
|
+
hashAt(value.certificateFingerprint, `${path}.certificateFingerprint`, errors);
|
|
198
|
+
if (value.profileFingerprint !== null) hashAt(value.profileFingerprint, `${path}.profileFingerprint`, errors);
|
|
199
|
+
timestampAt(value.expiresAt, `${path}.expiresAt`, errors);
|
|
200
|
+
stringAt(value.applicationId, `${path}.applicationId`, errors);
|
|
201
|
+
if (value.debuggable !== false) add(errors, `${path}.debuggable`, "must be false for a production artifact");
|
|
202
|
+
enumAt(value.installResult, `${path}.installResult`, errors, ["installed"]);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function validatePrerequisite(value, path, errors, candidateSha) {
|
|
206
|
+
if (!objectAt(value, path, errors, new Set(["status", "reportPath", "sha256", "candidateSha", "gateIds"]))) return;
|
|
207
|
+
enumAt(value.status, `${path}.status`, errors, ["pass"]);
|
|
208
|
+
relativePathAt(value.reportPath, `${path}.reportPath`, errors);
|
|
209
|
+
hashAt(value.sha256, `${path}.sha256`, errors);
|
|
210
|
+
commitAt(value.candidateSha, `${path}.candidateSha`, errors);
|
|
211
|
+
if (candidateSha !== undefined && value.candidateSha !== candidateSha) add(errors, `${path}.candidateSha`, `prerequisite candidate SHA mismatch: expected ${candidateSha}, got ${value.candidateSha}`);
|
|
212
|
+
if (!Array.isArray(value.gateIds) || value.gateIds.length === 0) add(errors, `${path}.gateIds`, "must contain at least one gate id");
|
|
213
|
+
else value.gateIds.forEach((gate, index) => stringAt(gate, `${path}.gateIds[${index}]`, errors));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function validatePrerequisites(value, errors, options) {
|
|
217
|
+
const path = "prerequisites";
|
|
218
|
+
if (!objectAt(value, path, errors, new Set(REQUIRED_PREREQUISITES))) return;
|
|
219
|
+
for (const key of REQUIRED_PREREQUISITES) {
|
|
220
|
+
if (!required(value[key], `${path}.${key}`, errors)) continue;
|
|
221
|
+
validatePrerequisite(value[key], `${path}.${key}`, errors, options.candidateSha);
|
|
222
|
+
}
|
|
223
|
+
const candidate = options.candidateSha ?? value.prd053?.candidateSha;
|
|
224
|
+
for (const key of REQUIRED_PREREQUISITES) {
|
|
225
|
+
if (value[key]?.candidateSha !== candidate) add(errors, `${path}.${key}.candidateSha`, `must match all prerequisite reports (${candidate ?? "candidate SHA"})`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function validateExecution(value, errors) {
|
|
230
|
+
const path = "execution";
|
|
231
|
+
if (!objectAt(value, path, errors, new Set(["installStartedAt", "launchStartedAt", "pid", "sessionNonce", "readyAt", "firstFrameAt", "frame300At", "frames", "nonBlankCaptureSha256", "gpuErrorCount", "arm64", "nativeGpu", "processLiveness", "assertionCount"]))) return;
|
|
232
|
+
for (const key of ["installStartedAt", "launchStartedAt", "readyAt", "firstFrameAt", "frame300At"]) timestampAt(value[key], `${path}.${key}`, errors);
|
|
233
|
+
finiteNumberAt(value.pid, `${path}.pid`, errors, { integer: true, minimum: 1 });
|
|
234
|
+
stringAt(value.sessionNonce, `${path}.sessionNonce`, errors);
|
|
235
|
+
finiteNumberAt(value.frames, `${path}.frames`, errors, { integer: true, minimum: 300 });
|
|
236
|
+
hashAt(value.nonBlankCaptureSha256, `${path}.nonBlankCaptureSha256`, errors);
|
|
237
|
+
finiteNumberAt(value.gpuErrorCount, `${path}.gpuErrorCount`, errors, { integer: true, minimum: 0 });
|
|
238
|
+
if (value.gpuErrorCount !== 0) add(errors, `${path}.gpuErrorCount`, "must equal zero");
|
|
239
|
+
if (value.arm64 !== true) add(errors, `${path}.arm64`, "must be true");
|
|
240
|
+
if (value.nativeGpu !== true) add(errors, `${path}.nativeGpu`, "must be true; software GPU is not physical evidence");
|
|
241
|
+
booleanAt(value.processLiveness, `${path}.processLiveness`, errors);
|
|
242
|
+
finiteNumberAt(value.assertionCount, `${path}.assertionCount`, errors, { integer: true, minimum: 1 });
|
|
243
|
+
if (value.processLiveness !== true) add(errors, `${path}.processLiveness`, "must be true for a passing physical report");
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function validateLifecycle(value, errors, execution) {
|
|
247
|
+
const path = "lifecycle";
|
|
248
|
+
if (!objectAt(value, path, errors, new Set(["events", "sameSession", "framesPaused", "framesAdvanced", "maxFrameIntervalMs", "surfaceValidAfterResume", "stateContinuity", "physicsStepDelta", "backgroundGapIntegrated"]))) return;
|
|
249
|
+
if (!Array.isArray(value.events)) add(errors, `${path}.events`, "must be an array");
|
|
250
|
+
else {
|
|
251
|
+
const expected = ["background", "foreground", "supported-rotation", "resume"];
|
|
252
|
+
if (value.events.length !== expected.length) add(errors, `${path}.events`, `must contain ${expected.length} ordered lifecycle observations`);
|
|
253
|
+
value.events.forEach((event, index) => {
|
|
254
|
+
const eventPath = `${path}.events[${index}]`;
|
|
255
|
+
if (!objectAt(event, eventPath, errors, new Set(["phase", "at", "sessionNonce", "pid", "frameCount", "viewport", "surfaceValid", "physicsStepCount"]))) return;
|
|
256
|
+
enumAt(event.phase, `${eventPath}.phase`, errors, expected);
|
|
257
|
+
timestampAt(event.at, `${eventPath}.at`, errors);
|
|
258
|
+
stringAt(event.sessionNonce, `${eventPath}.sessionNonce`, errors);
|
|
259
|
+
if (event.sessionNonce !== execution?.sessionNonce) add(errors, `${eventPath}.sessionNonce`, "must remain stable across lifecycle");
|
|
260
|
+
finiteNumberAt(event.pid, `${eventPath}.pid`, errors, { integer: true, minimum: 1 });
|
|
261
|
+
if (event.pid !== execution?.pid) add(errors, `${eventPath}.pid`, "must remain stable across lifecycle");
|
|
262
|
+
finiteNumberAt(event.frameCount, `${eventPath}.frameCount`, errors, { integer: true, minimum: 0 });
|
|
263
|
+
if (!isRecord(event.viewport)) add(errors, `${eventPath}.viewport`, "must be an object");
|
|
264
|
+
else {
|
|
265
|
+
finiteNumberAt(event.viewport.width, `${eventPath}.viewport.width`, errors, { integer: true, minimum: 1 });
|
|
266
|
+
finiteNumberAt(event.viewport.height, `${eventPath}.viewport.height`, errors, { integer: true, minimum: 1 });
|
|
267
|
+
}
|
|
268
|
+
booleanAt(event.surfaceValid, `${eventPath}.surfaceValid`, errors);
|
|
269
|
+
finiteNumberAt(event.physicsStepCount, `${eventPath}.physicsStepCount`, errors, { integer: true, minimum: 0 });
|
|
270
|
+
});
|
|
271
|
+
for (let index = 0; index < Math.min(value.events.length, 4); index += 1) {
|
|
272
|
+
if (value.events[index]?.phase !== ["background", "foreground", "supported-rotation", "resume"][index]) add(errors, `${path}.events[${index}].phase`, "lifecycle order is invalid");
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
booleanAt(value.sameSession, `${path}.sameSession`, errors);
|
|
276
|
+
booleanAt(value.framesPaused, `${path}.framesPaused`, errors);
|
|
277
|
+
booleanAt(value.framesAdvanced, `${path}.framesAdvanced`, errors);
|
|
278
|
+
finiteNumberAt(value.maxFrameIntervalMs, `${path}.maxFrameIntervalMs`, errors, { minimum: 0 });
|
|
279
|
+
booleanAt(value.surfaceValidAfterResume, `${path}.surfaceValidAfterResume`, errors);
|
|
280
|
+
booleanAt(value.stateContinuity, `${path}.stateContinuity`, errors);
|
|
281
|
+
finiteNumberAt(value.physicsStepDelta, `${path}.physicsStepDelta`, errors, { minimum: 0 });
|
|
282
|
+
if (value.backgroundGapIntegrated !== false) add(errors, `${path}.backgroundGapIntegrated`, "must be false");
|
|
283
|
+
if (value.sameSession !== true) add(errors, `${path}.sameSession`, "must be true for a physical resume report");
|
|
284
|
+
if (value.framesPaused !== true) add(errors, `${path}.framesPaused`, "must be true for a physical resume report");
|
|
285
|
+
if (value.framesAdvanced !== true) add(errors, `${path}.framesAdvanced`, "must be true for a physical resume report");
|
|
286
|
+
if (value.surfaceValidAfterResume !== true) add(errors, `${path}.surfaceValidAfterResume`, "must be true for a physical resume report");
|
|
287
|
+
if (value.stateContinuity !== true) add(errors, `${path}.stateContinuity`, "must be true for a physical resume report");
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function validateMultitouch(value, errors, path) {
|
|
291
|
+
if (!objectAt(value, path, errors, new Set(["status", "reportPath", "reportSha256", "candidateSha", "deviceClass", "maxPointers", "simultaneousMovementAndJump", "onePointerControl"]))) return;
|
|
292
|
+
enumAt(value.status, `${path}.status`, errors, ["pass"]);
|
|
293
|
+
relativePathAt(value.reportPath, `${path}.reportPath`, errors);
|
|
294
|
+
hashAt(value.reportSha256, `${path}.reportSha256`, errors);
|
|
295
|
+
commitAt(value.candidateSha, `${path}.candidateSha`, errors);
|
|
296
|
+
enumAt(value.deviceClass, `${path}.deviceClass`, errors, ["physical"]);
|
|
297
|
+
finiteNumberAt(value.maxPointers, `${path}.maxPointers`, errors, { integer: true, minimum: 2 });
|
|
298
|
+
if (value.maxPointers < 2) add(errors, `${path}.maxPointers`, "physical multitouch requirement failed: maxPointers must be >= 2");
|
|
299
|
+
if (value.simultaneousMovementAndJump !== true) add(errors, `${path}.simultaneousMovementAndJump`, "physical multitouch requirement failed");
|
|
300
|
+
validateControl(value.onePointerControl, `${path}.onePointerControl`, errors, "one-pointer control");
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function validatePhysics(value, errors, path) {
|
|
304
|
+
if (!objectAt(value, path, errors, new Set(["status", "reportPath", "reportSha256", "candidateSha", "deviceClass", "normalPublicApi", "wrongGravityControl", "wrongHeightControl", "wrongMaskControl"]))) return;
|
|
305
|
+
enumAt(value.status, `${path}.status`, errors, ["pass"]);
|
|
306
|
+
relativePathAt(value.reportPath, `${path}.reportPath`, errors);
|
|
307
|
+
hashAt(value.reportSha256, `${path}.reportSha256`, errors);
|
|
308
|
+
commitAt(value.candidateSha, `${path}.candidateSha`, errors);
|
|
309
|
+
enumAt(value.deviceClass, `${path}.deviceClass`, errors, ["physical"]);
|
|
310
|
+
booleanAt(value.normalPublicApi, `${path}.normalPublicApi`, errors);
|
|
311
|
+
if (value.normalPublicApi !== true) add(errors, `${path}.normalPublicApi`, "native physics scenario failed");
|
|
312
|
+
for (const key of ["wrongGravityControl", "wrongHeightControl", "wrongMaskControl"]) validateControl(value[key], `${path}.${key}`, errors, `native physics ${key.replace(/Control$/u, "")} control`);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function validateControl(value, path, errors, label) {
|
|
316
|
+
if (!objectAt(value, path, errors, new Set(["status", "exitCode", "observedRed", "reportSha256"]))) return;
|
|
317
|
+
enumAt(value.status, `${path}.status`, errors, ["fail"]);
|
|
318
|
+
finiteNumberAt(value.exitCode, `${path}.exitCode`, errors, { integer: true });
|
|
319
|
+
if (value.exitCode === 0) add(errors, `${path}.exitCode`, `${label} must have a nonzero exit code`);
|
|
320
|
+
stringAt(value.observedRed, `${path}.observedRed`, errors);
|
|
321
|
+
hashAt(value.reportSha256, `${path}.reportSha256`, errors);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function validateCollector(value, path, errors, { numeric = true } = {}) {
|
|
325
|
+
if (!objectAt(value, path, errors, new Set(["available", "source", "unit", "samples", "error"]))) return;
|
|
326
|
+
booleanAt(value.available, `${path}.available`, errors);
|
|
327
|
+
stringAt(value.source, `${path}.source`, errors);
|
|
328
|
+
stringAt(value.unit, `${path}.unit`, errors);
|
|
329
|
+
if (!Array.isArray(value.samples)) add(errors, `${path}.samples`, "must be an array");
|
|
330
|
+
else value.samples.forEach((sample, index) => {
|
|
331
|
+
const samplePath = `${path}.samples[${index}]`;
|
|
332
|
+
if (!objectAt(sample, samplePath, errors, new Set(["at", "value"]))) return;
|
|
333
|
+
timestampAt(sample.at, `${samplePath}.at`, errors);
|
|
334
|
+
if (numeric) finiteNumberAt(sample.value, `${samplePath}.value`, errors);
|
|
335
|
+
else stringAt(sample.value, `${samplePath}.value`, errors);
|
|
336
|
+
});
|
|
337
|
+
if (value.available === true) {
|
|
338
|
+
if (value.samples?.length === 0) add(errors, `${path}.samples`, "available collector must contain samples");
|
|
339
|
+
if (value.error !== null) add(errors, `${path}.error`, "must be null when available");
|
|
340
|
+
} else {
|
|
341
|
+
stringAt(value.error, `${path}.error`, errors);
|
|
342
|
+
if (value.samples?.length > 0) add(errors, `${path}.samples`, "unavailable collector must not contain samples");
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function validateTelemetry(value, errors) {
|
|
347
|
+
const path = "telemetry";
|
|
348
|
+
if (!objectAt(value, path, errors, new Set(["durationMs", "cadenceMs", "frame", "memory", "thermal", "battery"]))) return;
|
|
349
|
+
finiteNumberAt(value.durationMs, `${path}.durationMs`, errors, { minimum: 1 });
|
|
350
|
+
finiteNumberAt(value.cadenceMs, `${path}.cadenceMs`, errors, { minimum: 1 });
|
|
351
|
+
validateCollector(value.frame, `${path}.frame`, errors);
|
|
352
|
+
validateCollector(value.memory, `${path}.memory`, errors);
|
|
353
|
+
validateCollector(value.thermal, `${path}.thermal`, errors, { numeric: false });
|
|
354
|
+
validateCollector(value.battery, `${path}.battery`, errors);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function validateArtifacts(value, errors) {
|
|
358
|
+
const path = "artifacts";
|
|
359
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
360
|
+
add(errors, path, "must contain at least one artifact");
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
value.forEach((artifact, index) => {
|
|
364
|
+
const artifactPath = `${path}[${index}]`;
|
|
365
|
+
if (!objectAt(artifact, artifactPath, errors, new Set(["path", "sha256", "size", "producerCommand", "retention"]))) return;
|
|
366
|
+
relativePathAt(artifact.path, `${artifactPath}.path`, errors);
|
|
367
|
+
hashAt(artifact.sha256, `${artifactPath}.sha256`, errors);
|
|
368
|
+
finiteNumberAt(artifact.size, `${artifactPath}.size`, errors, { integer: true, minimum: 1 });
|
|
369
|
+
stringAt(artifact.producerCommand, `${artifactPath}.producerCommand`, errors);
|
|
370
|
+
enumAt(artifact.retention, `${artifactPath}.retention`, errors, ["ignored-raw", "committed-summary"]);
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function validateGateEvidence(value, errors) {
|
|
375
|
+
const path = "gateEvidence";
|
|
376
|
+
if (!Array.isArray(value)) {
|
|
377
|
+
add(errors, path, "must be an array");
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
const seen = new Set();
|
|
381
|
+
value.forEach((gate, index) => {
|
|
382
|
+
const gatePath = `${path}[${index}]`;
|
|
383
|
+
if (!objectAt(gate, gatePath, errors, new Set(["gateId", "finalResult", "negativeControlCommand", "redObservation", "exitCode"]))) return;
|
|
384
|
+
stringAt(gate.gateId, `${gatePath}.gateId`, errors);
|
|
385
|
+
if (seen.has(gate.gateId)) add(errors, `${gatePath}.gateId`, "duplicate gate id");
|
|
386
|
+
seen.add(gate.gateId);
|
|
387
|
+
if (!REQUIRED_GATE_IDS.includes(gate.gateId)) add(errors, `${gatePath}.gateId`, "unknown gate id");
|
|
388
|
+
enumAt(gate.finalResult, `${gatePath}.finalResult`, errors, ["pass"]);
|
|
389
|
+
stringAt(gate.negativeControlCommand, `${gatePath}.negativeControlCommand`, errors);
|
|
390
|
+
stringAt(gate.redObservation, `${gatePath}.redObservation`, errors);
|
|
391
|
+
finiteNumberAt(gate.exitCode, `${gatePath}.exitCode`, errors, { integer: true });
|
|
392
|
+
if (gate.exitCode === 0) add(errors, `${gatePath}.exitCode`, "negative control must have a nonzero exit code");
|
|
393
|
+
if (typeof gate.redObservation === "string" && !/red|fail|reject/iu.test(gate.redObservation)) add(errors, `${gatePath}.redObservation`, "must describe the observed red/rejected control");
|
|
394
|
+
});
|
|
395
|
+
for (const gateId of REQUIRED_GATE_IDS) if (!seen.has(gateId)) add(errors, `${path}.${gateId}`, "required gate evidence is missing");
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function validateConsumption(value, errors, candidateSha) {
|
|
399
|
+
const path = "consumption";
|
|
400
|
+
if (!objectAt(value, path, errors, new Set(["multitouch", "physics"]))) return;
|
|
401
|
+
validateMultitouch(value.multitouch, errors, `${path}.multitouch`);
|
|
402
|
+
validatePhysics(value.physics, errors, `${path}.physics`);
|
|
403
|
+
for (const key of ["multitouch", "physics"]) if (value[key]?.candidateSha !== candidateSha) add(errors, `${path}.${key}.candidateSha`, `must match candidate SHA ${candidateSha ?? "from source"}`);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
export function validatePhysicalDeviceEvidence(evidence, options = {}) {
|
|
407
|
+
const errors = [];
|
|
408
|
+
if (!objectAt(evidence, "evidence", errors, ROOT_KEYS)) return { valid: false, errors };
|
|
409
|
+
if (evidence.schemaVersion !== 1) add(errors, "schemaVersion", "must equal 1");
|
|
410
|
+
validateIdentity(evidence.identity, errors);
|
|
411
|
+
validateSource(evidence.source, errors, options);
|
|
412
|
+
validateDevice(evidence.device, errors, options);
|
|
413
|
+
validateSigning(evidence.signing, errors);
|
|
414
|
+
const candidateSha = options.candidateSha ?? evidence.source?.headSha;
|
|
415
|
+
validatePrerequisites(evidence.prerequisites, errors, { candidateSha });
|
|
416
|
+
validateExecution(evidence.execution, errors);
|
|
417
|
+
validateLifecycle(evidence.lifecycle, errors, evidence.execution);
|
|
418
|
+
validateConsumption(evidence.consumption, errors, candidateSha);
|
|
419
|
+
validateTelemetry(evidence.telemetry, errors);
|
|
420
|
+
validateArtifacts(evidence.artifacts, errors);
|
|
421
|
+
validateGateEvidence(evidence.gateEvidence, errors);
|
|
422
|
+
if (evidence.identity?.verdict === "pass" && evidence.identity?.blockers?.length > 0) add(errors, "identity.blockers", "a pass report cannot contain blockers");
|
|
423
|
+
return { valid: errors.length === 0, errors: [...new Set(errors)] };
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
export function assertValidPhysicalDeviceEvidence(evidence, options = {}) {
|
|
427
|
+
const result = validatePhysicalDeviceEvidence(evidence, options);
|
|
428
|
+
if (!result.valid) throw new EvidenceValidationError(result.errors);
|
|
429
|
+
return evidence;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
export function physicalDeviceEvidenceV1(evidence, options = {}) {
|
|
433
|
+
return validatePhysicalDeviceEvidence(evidence, options);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
physicalDeviceEvidenceV1.schema = PHYSICAL_EVIDENCE_SCHEMA;
|
|
437
|
+
|
|
438
|
+
export function sha256(value) {
|
|
439
|
+
return createHash("sha256").update(value).digest("hex");
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
export function sha256File(path) {
|
|
443
|
+
return sha256(readFileSync(path));
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
export function hashIdentifier(identifier) {
|
|
447
|
+
return sha256(identifier);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function deepMerge(base, overrides) {
|
|
451
|
+
if (!isRecord(overrides)) return base;
|
|
452
|
+
for (const [key, value] of Object.entries(overrides)) {
|
|
453
|
+
if (isRecord(value) && isRecord(base[key])) deepMerge(base[key], value);
|
|
454
|
+
else base[key] = value;
|
|
455
|
+
}
|
|
456
|
+
return base;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
const sampleAt = "2026-08-09T00:00:00.000Z";
|
|
460
|
+
const sampleHash = "a".repeat(64);
|
|
461
|
+
|
|
462
|
+
export function createEvidenceFixture({ platform = "android", candidateSha = "8bcf0553f38655b8db425d64f37cd19ff4db7034", identifier = "physical-device-056", overrides = {} } = {}) {
|
|
463
|
+
const isAndroid = platform === "android";
|
|
464
|
+
const fixture = {
|
|
465
|
+
schemaVersion: 1,
|
|
466
|
+
identity: {
|
|
467
|
+
schemaVersion: 1,
|
|
468
|
+
runId: `prd056-${platform}-fixture`,
|
|
469
|
+
startedAt: sampleAt,
|
|
470
|
+
endedAt: "2026-08-09T00:00:30.000Z",
|
|
471
|
+
verdict: "pass",
|
|
472
|
+
blockers: [],
|
|
473
|
+
evidenceClass: "physical-device",
|
|
474
|
+
},
|
|
475
|
+
source: {
|
|
476
|
+
remote: "https://github.com/ThreeNativeHQ/threenative.git",
|
|
477
|
+
branch: "main",
|
|
478
|
+
headSha: candidateSha,
|
|
479
|
+
worktree: "clean",
|
|
480
|
+
artifactSourceSha: candidateSha,
|
|
481
|
+
packageVersion: "0.1.13",
|
|
482
|
+
artifactSha256: sampleHash,
|
|
483
|
+
releaseRun: null,
|
|
484
|
+
publishedPackage: null,
|
|
485
|
+
promotedConsumer: null,
|
|
486
|
+
},
|
|
487
|
+
device: {
|
|
488
|
+
platform,
|
|
489
|
+
kind: "physical",
|
|
490
|
+
identifierHash: hashIdentifier(identifier),
|
|
491
|
+
name: isAndroid ? "Fixture Android" : "Fixture iPhone",
|
|
492
|
+
manufacturer: isAndroid ? "Fixture OEM" : "Apple",
|
|
493
|
+
model: isAndroid ? "Fixture Arm64" : "iPhone Fixture",
|
|
494
|
+
osVersion: isAndroid ? "15" : "18.6",
|
|
495
|
+
osBuild: isAndroid ? "AP4A.250000.000" : "22G000",
|
|
496
|
+
cpuAbi: isAndroid ? "arm64-v8a" : "arm64",
|
|
497
|
+
gpu: isAndroid ? "Adreno (TM) 740" : "Apple GPU",
|
|
498
|
+
driver: isAndroid ? "Vulkan physical driver" : "Metal device driver",
|
|
499
|
+
screenModes: [{ width: 1920, height: 1080, orientation: "landscape" }],
|
|
500
|
+
},
|
|
501
|
+
signing: {
|
|
502
|
+
verificationCommand: isAndroid ? "apksigner verify --print-certs candidate.apk" : "codesign --verify --strict --deep candidate.app",
|
|
503
|
+
signerId: isAndroid ? "android-signer-fixture" : "apple-team-fixture",
|
|
504
|
+
certificateFingerprint: sampleHash,
|
|
505
|
+
profileFingerprint: isAndroid ? null : sampleHash,
|
|
506
|
+
expiresAt: "2027-08-09T00:00:00.000Z",
|
|
507
|
+
applicationId: isAndroid ? "com.threenative.game" : "dev.threenative.runtime",
|
|
508
|
+
debuggable: false,
|
|
509
|
+
installResult: "installed",
|
|
510
|
+
},
|
|
511
|
+
prerequisites: Object.fromEntries(REQUIRED_PREREQUISITES.map((key) => [key, {
|
|
512
|
+
status: "pass",
|
|
513
|
+
reportPath: `.runtime/prd056/${platform}/${key}.json`,
|
|
514
|
+
sha256: sampleHash,
|
|
515
|
+
candidateSha,
|
|
516
|
+
gateIds: [key],
|
|
517
|
+
}])),
|
|
518
|
+
execution: {
|
|
519
|
+
installStartedAt: sampleAt,
|
|
520
|
+
launchStartedAt: "2026-08-09T00:00:01.000Z",
|
|
521
|
+
pid: 5600,
|
|
522
|
+
sessionNonce: `fixture-session-${platform}`,
|
|
523
|
+
readyAt: "2026-08-09T00:00:02.000Z",
|
|
524
|
+
firstFrameAt: "2026-08-09T00:00:02.100Z",
|
|
525
|
+
frame300At: "2026-08-09T00:00:07.100Z",
|
|
526
|
+
frames: 300,
|
|
527
|
+
nonBlankCaptureSha256: sampleHash,
|
|
528
|
+
gpuErrorCount: 0,
|
|
529
|
+
arm64: true,
|
|
530
|
+
nativeGpu: true,
|
|
531
|
+
processLiveness: true,
|
|
532
|
+
assertionCount: 12,
|
|
533
|
+
},
|
|
534
|
+
lifecycle: {
|
|
535
|
+
events: ["background", "foreground", "supported-rotation", "resume"].map((phase, index) => ({
|
|
536
|
+
phase,
|
|
537
|
+
at: `2026-08-09T00:00:${String(10 + index).padStart(2, "0")}.000Z`,
|
|
538
|
+
sessionNonce: `fixture-session-${platform}`,
|
|
539
|
+
pid: 5600,
|
|
540
|
+
frameCount: 300 + index,
|
|
541
|
+
viewport: { width: 1920, height: 1080 },
|
|
542
|
+
surfaceValid: phase !== "background",
|
|
543
|
+
physicsStepCount: 0,
|
|
544
|
+
})),
|
|
545
|
+
sameSession: true,
|
|
546
|
+
framesPaused: true,
|
|
547
|
+
framesAdvanced: true,
|
|
548
|
+
maxFrameIntervalMs: 33,
|
|
549
|
+
surfaceValidAfterResume: true,
|
|
550
|
+
stateContinuity: true,
|
|
551
|
+
physicsStepDelta: 0,
|
|
552
|
+
backgroundGapIntegrated: false,
|
|
553
|
+
},
|
|
554
|
+
consumption: {
|
|
555
|
+
multitouch: {
|
|
556
|
+
status: "pass",
|
|
557
|
+
reportPath: `.runtime/prd056/${platform}/prd053.json`,
|
|
558
|
+
reportSha256: sampleHash,
|
|
559
|
+
candidateSha,
|
|
560
|
+
deviceClass: "physical",
|
|
561
|
+
maxPointers: 2,
|
|
562
|
+
simultaneousMovementAndJump: true,
|
|
563
|
+
onePointerControl: { status: "fail", exitCode: 1, observedRed: "RED observed: one-pointer control assertion failed", reportSha256: sampleHash },
|
|
564
|
+
},
|
|
565
|
+
physics: {
|
|
566
|
+
status: "pass",
|
|
567
|
+
reportPath: `.runtime/prd056/${platform}/prd046.json`,
|
|
568
|
+
reportSha256: sampleHash,
|
|
569
|
+
candidateSha,
|
|
570
|
+
deviceClass: "physical",
|
|
571
|
+
normalPublicApi: true,
|
|
572
|
+
wrongGravityControl: { status: "fail", exitCode: 1, observedRed: "RED observed: wrong gravity control failed", reportSha256: sampleHash },
|
|
573
|
+
wrongHeightControl: { status: "fail", exitCode: 1, observedRed: "RED observed: wrong height control failed", reportSha256: sampleHash },
|
|
574
|
+
wrongMaskControl: { status: "fail", exitCode: 1, observedRed: "RED observed: wrong mask control failed", reportSha256: sampleHash },
|
|
575
|
+
},
|
|
576
|
+
},
|
|
577
|
+
telemetry: {
|
|
578
|
+
durationMs: 30000,
|
|
579
|
+
cadenceMs: 1000,
|
|
580
|
+
frame: { available: true, source: "fixture frame collector", unit: "ms", samples: [{ at: sampleAt, value: 16.7 }], error: null },
|
|
581
|
+
memory: { available: true, source: isAndroid ? "adb shell dumpsys meminfo" : "devicectl process memory", unit: "bytes", samples: [{ at: sampleAt, value: 1000000 }], error: null },
|
|
582
|
+
thermal: { available: true, source: isAndroid ? "adb shell dumpsys thermalservice" : "ProcessInfo thermal state", unit: "state", samples: [{ at: sampleAt, value: "nominal" }], error: null },
|
|
583
|
+
battery: { available: true, source: isAndroid ? "adb shell dumpsys battery" : "IOKit/ProcessInfo battery bridge", unit: "percent", samples: [{ at: sampleAt, value: 90 }], error: null },
|
|
584
|
+
},
|
|
585
|
+
artifacts: [{ path: `.runtime/prd056/${platform}/raw-report.json`, sha256: sampleHash, size: 1, producerCommand: "native:qualify:physical", retention: "ignored-raw" }],
|
|
586
|
+
gateEvidence: REQUIRED_GATE_IDS.map((gateId) => ({
|
|
587
|
+
gateId,
|
|
588
|
+
finalResult: "pass",
|
|
589
|
+
negativeControlCommand: `native:qualify:physical --control ${gateId}`,
|
|
590
|
+
redObservation: `RED observed: ${gateId} control failed closed`,
|
|
591
|
+
exitCode: 1,
|
|
592
|
+
})),
|
|
593
|
+
};
|
|
594
|
+
return deepMerge(fixture, overrides);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
function jsonFiles(directory) {
|
|
598
|
+
if (!existsSync(directory)) return [];
|
|
599
|
+
const files = [];
|
|
600
|
+
for (const entry of readdirSync(directory)) {
|
|
601
|
+
const path = join(directory, entry);
|
|
602
|
+
if (statSync(path).isDirectory()) files.push(...jsonFiles(path));
|
|
603
|
+
else if (entry.endsWith(".json")) files.push(path);
|
|
604
|
+
}
|
|
605
|
+
return files;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
export function rollupPhysicalDeviceEvidence(directory, candidateSha) {
|
|
609
|
+
const files = jsonFiles(directory).filter((path) => !["summary.json", "rollup.json", "qualification-result.json"].includes(path.split(sep).pop()));
|
|
610
|
+
if (files.length === 0) return { status: "blocked", code: "TN_QUALIFY_PREREQUISITE_REPORT_MISSING", blockers: ["android physical evidence report is absent", "ios physical evidence report is absent"], reports: [] };
|
|
611
|
+
const reports = [];
|
|
612
|
+
const errors = [];
|
|
613
|
+
for (const path of files) {
|
|
614
|
+
let evidence;
|
|
615
|
+
try {
|
|
616
|
+
evidence = JSON.parse(readFileSync(path, "utf8"));
|
|
617
|
+
} catch (error) {
|
|
618
|
+
errors.push(`${relative(directory, path).split(sep).join("/")}: invalid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
619
|
+
continue;
|
|
620
|
+
}
|
|
621
|
+
const validation = validatePhysicalDeviceEvidence(evidence, { candidateSha });
|
|
622
|
+
if (!validation.valid) errors.push(...validation.errors.map((error) => `${relative(directory, path).split(sep).join("/")}: ${error}`));
|
|
623
|
+
reports.push({ path, evidence });
|
|
624
|
+
}
|
|
625
|
+
if (errors.length > 0) return { status: "fail", code: "TN_QUALIFY_EVIDENCE_INVALID", errors, reports };
|
|
626
|
+
const byPlatform = new Map();
|
|
627
|
+
for (const { path, evidence } of reports) {
|
|
628
|
+
const platform = evidence.device.platform;
|
|
629
|
+
if (byPlatform.has(platform)) {
|
|
630
|
+
errors.push(`${relative(directory, path).split(sep).join("/")}: duplicate ${platform} physical evidence report`);
|
|
631
|
+
} else {
|
|
632
|
+
byPlatform.set(platform, evidence);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
if (errors.length > 0) return { status: "fail", code: "TN_QUALIFY_EVIDENCE_INVALID", errors, reports };
|
|
636
|
+
const blockers = [];
|
|
637
|
+
for (const platform of ["android", "ios"]) {
|
|
638
|
+
const report = byPlatform.get(platform);
|
|
639
|
+
if (!report) blockers.push(`${platform} physical evidence report is absent`);
|
|
640
|
+
else if (report.identity.verdict !== "pass") blockers.push(`${platform} report verdict is ${report.identity.verdict}`);
|
|
641
|
+
}
|
|
642
|
+
if (blockers.length > 0) return { status: "blocked", code: "TN_QUALIFY_PREREQUISITE_REPORT_MISSING", blockers, reports };
|
|
643
|
+
return { status: "pass", code: "TN_QUALIFY_ROLLUP_PASS", reports };
|
|
644
|
+
}
|