feat(application): add cross-layer graph workflows
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import {
|
||||
applicationVersionComparisonResultSchema,
|
||||
compareApplicationVersionsInputSchema,
|
||||
} from "../domain/javascriptApplicationVersionComparisonSchemas.js";
|
||||
import {
|
||||
applicationFeatureTraceResultSchema,
|
||||
traceApplicationFeatureInputSchema,
|
||||
} from "../domain/javascriptFeatureTraceSchemas.js";
|
||||
import { evidenceEnvelopeSchema } from "../domain/evidence.js";
|
||||
import type { ToolContract } from "./toolContracts.js";
|
||||
import {
|
||||
JAVASCRIPT_APPLICATION_VERSION_COMPARISON_EXAMPLE,
|
||||
JAVASCRIPT_FEATURE_TRACE_EXAMPLE,
|
||||
} from "./javascriptApplicationWorkflowExamples.js";
|
||||
|
||||
const traceOutputSchema = evidenceEnvelopeSchema
|
||||
.omit({ normalized_result: true })
|
||||
.extend({ normalized_result: applicationFeatureTraceResultSchema });
|
||||
const comparisonOutputSchema = evidenceEnvelopeSchema
|
||||
.omit({ normalized_result: true })
|
||||
.extend({ normalized_result: applicationVersionComparisonResultSchema });
|
||||
|
||||
/** Provider-neutral graph workflow contracts shared by MCP and CLI adapters. */
|
||||
export const APPLICATION_TOOL_CONTRACTS = [
|
||||
{
|
||||
name: "trace_application_feature",
|
||||
description:
|
||||
"Trace a typed literal seed through an authenticated JavaScript Application Graph with explicit direction, depth, node, edge, and path bounds. Original static, native, passive-runtime, inferred, and unknown authorities remain distinct; native addon handoffs never open a provider or execute the application.",
|
||||
kind: "application",
|
||||
inputSchema: traceApplicationFeatureInputSchema,
|
||||
outputSchema: traceOutputSchema,
|
||||
annotations: {
|
||||
readOnlyHint: true,
|
||||
destructiveHint: false,
|
||||
idempotentHint: true,
|
||||
openWorldHint: false,
|
||||
},
|
||||
examples: [
|
||||
{
|
||||
title: "Trace one module seed through a retained application graph",
|
||||
input: JAVASCRIPT_FEATURE_TRACE_EXAMPLE,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "compare_application_versions",
|
||||
description:
|
||||
"Compare two authenticated JavaScript Application Graph versions using unique-only exact digest, module source digest, source-map identity, structural fingerprint, and non-module semantic-key tiers. Reports added, removed, changed, ambiguous, and unknown entities plus a bounded changed_from graph without fuzzy or module-ordinal pairing.",
|
||||
kind: "application",
|
||||
inputSchema: compareApplicationVersionsInputSchema,
|
||||
outputSchema: comparisonOutputSchema,
|
||||
annotations: {
|
||||
readOnlyHint: true,
|
||||
destructiveHint: false,
|
||||
idempotentHint: true,
|
||||
openWorldHint: false,
|
||||
},
|
||||
examples: [
|
||||
{
|
||||
title: "Compare authenticated static and reconciled application graphs",
|
||||
input: JAVASCRIPT_APPLICATION_VERSION_COMPARISON_EXAMPLE,
|
||||
},
|
||||
],
|
||||
},
|
||||
] as const satisfies readonly ToolContract[];
|
||||
@@ -0,0 +1,64 @@
|
||||
import { createEvidence } from "../domain/evidence.js";
|
||||
import { reconcileJavaScriptRuntime } from "../domain/javascriptRuntimeReconciliation.js";
|
||||
import {
|
||||
JAVASCRIPT_APPLICATION_EVIDENCE_EXAMPLE,
|
||||
JAVASCRIPT_RUNTIME_RECONCILIATION_EXAMPLE,
|
||||
} from "./javascriptRuntimeReconciliationExample.js";
|
||||
|
||||
const reconciliation = reconcileJavaScriptRuntime(
|
||||
JAVASCRIPT_RUNTIME_RECONCILIATION_EXAMPLE,
|
||||
);
|
||||
const reconciliationEvidence = createEvidence(
|
||||
undefined,
|
||||
{
|
||||
id: "rea-javascript-runtime-reconciliation",
|
||||
name: "REA JavaScript runtime reconciliation",
|
||||
version: "1",
|
||||
},
|
||||
{
|
||||
predicateType: "rea.javascript-runtime-reconciliation/v1",
|
||||
operation: "reconcile_javascript_runtime",
|
||||
parameters: {
|
||||
static_layers:
|
||||
JAVASCRIPT_RUNTIME_RECONCILIATION_EXAMPLE.static_layers.map(
|
||||
({ role, analysis }) => ({
|
||||
role,
|
||||
evidence_id: analysis.evidence_id,
|
||||
runtime_mappings: [],
|
||||
}),
|
||||
),
|
||||
runtime_evidence_ids:
|
||||
JAVASCRIPT_RUNTIME_RECONCILIATION_EXAMPLE.runtime_observations.map(
|
||||
({ evidence_id: id }) => id,
|
||||
),
|
||||
limits: {
|
||||
max_runtime_entities: 10_000,
|
||||
max_reconciliation_items: 20_000,
|
||||
max_static_load_states: 20_000,
|
||||
},
|
||||
},
|
||||
result: reconciliation,
|
||||
confidence: "inferred",
|
||||
authority: "analyst-inference",
|
||||
limitations: reconciliation.limitations,
|
||||
evidenceLinks: reconciliation.evidence_links,
|
||||
},
|
||||
);
|
||||
|
||||
/** Valid public trace request without proprietary artifacts. */
|
||||
export const JAVASCRIPT_FEATURE_TRACE_EXAMPLE = {
|
||||
application: JAVASCRIPT_APPLICATION_EVIDENCE_EXAMPLE,
|
||||
seed: {
|
||||
kind: "module" as const,
|
||||
value: "renderer.js",
|
||||
match: "exact" as const,
|
||||
case_sensitive: false,
|
||||
},
|
||||
direction: "both" as const,
|
||||
};
|
||||
|
||||
/** Valid static/runtime graph pair demonstrating comparison authority. */
|
||||
export const JAVASCRIPT_APPLICATION_VERSION_COMPARISON_EXAMPLE = {
|
||||
left: JAVASCRIPT_APPLICATION_EVIDENCE_EXAMPLE,
|
||||
right: reconciliationEvidence,
|
||||
};
|
||||
@@ -132,6 +132,9 @@ const staticEvidence = createEvidence(
|
||||
},
|
||||
);
|
||||
|
||||
/** Minimal valid static application Evidence for graph workflow examples. */
|
||||
export const JAVASCRIPT_APPLICATION_EVIDENCE_EXAMPLE = staticEvidence;
|
||||
|
||||
const runtimeEvidence = createEvidence(
|
||||
undefined,
|
||||
{
|
||||
|
||||
@@ -114,9 +114,13 @@ export const PROMPT_CONTRACTS = [
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
tools: ["binary_session", "open_binary"],
|
||||
tools: [
|
||||
"binary_session",
|
||||
"open_binary",
|
||||
"analyze_javascript_application",
|
||||
],
|
||||
instruction:
|
||||
"Inspect provider availability and effects first. Open target_path only when no matching target is active.",
|
||||
"Inspect provider availability and effects first. For an approved JavaScript/Electron artifact, reconstruct its application graph without execution; otherwise open target_path only when no matching target is active.",
|
||||
},
|
||||
{
|
||||
tools: ["list_documents", "set_current_document", "binary_overview"],
|
||||
@@ -128,6 +132,11 @@ export const PROMPT_CONTRACTS = [
|
||||
instruction:
|
||||
"Search in literal mode first, follow every continuation needed for the stated scope, and resolve selected procedures to canonical addresses.",
|
||||
},
|
||||
{
|
||||
tools: ["trace_application_feature"],
|
||||
instruction:
|
||||
"When authenticated application-graph Evidence exists, trace a typed literal route, API, channel, module, string, or native export through a bounded cross-layer subgraph before native localization.",
|
||||
},
|
||||
{
|
||||
tools: [
|
||||
"analyze_function",
|
||||
@@ -179,6 +188,15 @@ export const PROMPT_CONTRACTS = [
|
||||
instruction:
|
||||
"Inventory each target independently before extraction. Follow nodes, occurrences, and edges to completion and retain every Evidence page for each manifest.",
|
||||
},
|
||||
{
|
||||
tools: [
|
||||
"analyze_javascript_application",
|
||||
"reconcile_javascript_runtime",
|
||||
"compare_application_versions",
|
||||
],
|
||||
instruction:
|
||||
"For JavaScript/Electron versions, reconstruct each approved artifact independently, optionally reconcile separately retained passive runtime Evidence, then compare authenticated graphs with unique-only identity tiers. Keep ambiguous and incomplete matches unknown.",
|
||||
},
|
||||
{
|
||||
tools: ["export_evidence_bundle", "compare_artifacts"],
|
||||
instruction:
|
||||
|
||||
@@ -24,6 +24,7 @@ export type ToolKind =
|
||||
| "artifact-provider"
|
||||
| "browser-provider"
|
||||
| "electron-provider"
|
||||
| "application"
|
||||
| "session";
|
||||
|
||||
/** Single source of truth for a public MCP tool. */
|
||||
|
||||
@@ -28,6 +28,7 @@ import { NATIVE_TOOL_CONTRACTS } from "./nativeToolContracts.js";
|
||||
import { ARTIFACT_TOOL_CONTRACTS } from "./artifactToolContracts.js";
|
||||
import { BROWSER_TOOL_CONTRACTS } from "./browserToolContracts.js";
|
||||
import { ELECTRON_TOOL_CONTRACTS } from "./electronToolContracts.js";
|
||||
import { APPLICATION_TOOL_CONTRACTS } from "./applicationToolContracts.js";
|
||||
import {
|
||||
closeBinaryInputSchema,
|
||||
openBinaryInputSchema,
|
||||
@@ -526,5 +527,6 @@ export const TOOL_CONTRACTS = [
|
||||
...ARTIFACT_TOOL_CONTRACTS,
|
||||
...BROWSER_TOOL_CONTRACTS,
|
||||
...ELECTRON_TOOL_CONTRACTS,
|
||||
...APPLICATION_TOOL_CONTRACTS,
|
||||
...SESSION_TOOL_CONTRACTS,
|
||||
] as const;
|
||||
|
||||
Reference in New Issue
Block a user