Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

fix(runtime): preserve deterministic context identity

morluto9bd2ac590c00
diff --git a/src/browser/V8InspectorCaptureProjection.ts b/src/browser/V8InspectorCaptureProjection.ts
index 63295202b..1d0adf110 100644
--- a/src/browser/V8InspectorCaptureProjection.ts
+++ b/src/browser/V8InspectorCaptureProjection.ts
@@ -68,7 +68,11 @@ export const finalizeInspectorCapture = async ({
scripts.set(script.script_key, script);
}
const items = [...scripts.values()].sort((left, right) =>
- left.script_key.localeCompare(right.script_key),
+ left.script_key < right.script_key
+ ? -1
+ : left.script_key > right.script_key
+ ? 1
+ : 0,
);
const contexts = [...state.contexts.values()]
.map((context) => ({
@@ -77,7 +81,13 @@ export const finalizeInspectorCapture = async ({
name: null,
origin: context.origin,
}))
- .sort((left, right) => left.context_key.localeCompare(right.context_key));
+ .sort((left, right) =>
+ left.context_key < right.context_key
+ ? -1
+ : left.context_key > right.context_key
+ ? 1
+ : 0,
+ );
return {
schema_version: 1,
runtime,
@@ -132,6 +142,7 @@ const scriptFromDraft = (
): JavaScriptRuntimeObservation["scripts"]["items"][number] => {
const stable = JSON.stringify({
location,
+ execution_context_key: draft.executionContextKey,
cdp_hash: draft.cdpHash,
length: draft.length,
is_module: draft.isModule,
diff --git a/src/browser/V8InspectorProvider.ts b/src/browser/V8InspectorProvider.ts
index cb0b11da2..19a05de40 100644
--- a/src/browser/V8InspectorProvider.ts
+++ b/src/browser/V8InspectorProvider.ts
@@ -110,7 +110,9 @@ export class V8InspectorProvider implements JavaScriptRuntimeObservationPort {
}
allowed.push({ ...target, location: decision.location });
}
- allowed.sort((left, right) => left.id.localeCompare(right.id));
+ allowed.sort((left, right) =>
+ left.id < right.id ? -1 : left.id > right.id ? 1 : 0,
+ );
const items = allowed
.slice(input.offset, input.offset + input.limit)
.map(projectTarget);
diff --git a/src/domain/browserScenarioNormalization.ts b/src/domain/browserScenarioNormalization.ts
index 9d3f53af1..24f6a2f08 100644
--- a/src/domain/browserScenarioNormalization.ts
+++ b/src/domain/browserScenarioNormalization.ts
@@ -26,7 +26,9 @@ export const commitBrowserScenarioNormalization = (
...rule,
artifacts: [...rule.artifacts].sort(),
}))
- .sort((left, right) => left.rule_id.localeCompare(right.rule_id));
+ .sort((left, right) =>
+ left.rule_id < right.rule_id ? -1 : left.rule_id > right.rule_id ? 1 : 0,
+ );
const commitment = { built_in_rules: [...BUILT_IN_RULES], rules };
return { ...commitment, sha256: digestCanonicalJson(commitment) };
};
diff --git a/src/domain/reconstructionReadinessFindingHelpers.ts b/src/domain/reconstructionReadinessFindingHelpers.ts
index 3b79581c6..719008dbd 100644
--- a/src/domain/reconstructionReadinessFindingHelpers.ts
+++ b/src/domain/reconstructionReadinessFindingHelpers.ts
@@ -40,7 +40,8 @@ export const readinessFinding = (
export const readinessFindingOrder = (
left: ReadinessFinding,
right: ReadinessFinding,
-): number =>
- `${left.stage_id}:${left.code}:${left.detail}`.localeCompare(
- `${right.stage_id}:${right.code}:${right.detail}`,
- );
+): number => {
+ const leftKey = `${left.stage_id}:${left.code}:${left.detail}`;
+ const rightKey = `${right.stage_id}:${right.code}:${right.detail}`;
+ return leftKey < rightKey ? -1 : leftKey > rightKey ? 1 : 0;
+};