Appearance
Migrate GraphIR 1 and 2 data to GraphIR 3
Coral 0.2.6 uses @graph-ir/core@0.2.2 and accepts validated GraphIR 3.0 at its public GraphIR boundaries. Coral 0.2.5 used core 0.2.1 and GraphIR 2.0. This is historical 0.2.6 GraphIR API guidance. Use the matching package version for these adapters. For the Coral 0.2.9 saved-source reader, see the language API; migration does not create authored Coral.
GraphIR 1 to GraphIR 2
Use the core package's named migrateIR adapter at the load boundary. A successful first migration returns a GraphIR 2 value. Pass that exact result to migrateGraphIR2To3; only the validated GraphIR 3 result crosses the language, render, viz, or MCP boundary.
ts
import {
migrateGraphIR2To3,
migrateIR,
type GraphIR,
type GraphIR2,
} from '@graph-ir/core';
import { convertGraphToFlow } from '@coral-viz/viz';
const storedGraphIR1: unknown = {
version: '1.0.0',
id: 'stored',
nodes: [{ id: 'service', type: 'service' }],
edges: [],
};
const result = migrateIR(storedGraphIR1);
if (!result.success || !result.migrated) {
throw new Error(result.errors.join('\n'));
}
const graph2: GraphIR2 = result.migrated;
const upgraded = migrateGraphIR2To3(graph2);
if (!upgraded.success || !upgraded.migrated) {
throw new Error(upgraded.errors.join('\n'));
}
const graph: GraphIR = upgraded.migrated;
// Projected edges use the `compatibility` type and shared marker URLs. A
// standalone <ReactFlow> host registers
// `edgeTypes={{ compatibility: CompatibilityEdge }}` and renders
// `<EndpointMarkerDefinitions edges={flow.edges} />`; CoralEditor does both.
const flow = convertGraphToFlow(graph);
if (flow.nodes.length !== 1) throw new Error('Migrated graph was not projected');
const ambiguousGraphIR1: unknown = {
version: '1.0.0',
id: 'ambiguous',
nodes: [
{ id: 'a', type: 'service' },
{ id: 'b', type: 'database' },
],
edges: [{
id: 'edge',
source: 'a',
target: 'b',
routingPoints: [{ x: 1, y: 2 }],
}],
};
const refused = migrateIR(ambiguousGraphIR1);
if (refused.success || !refused.losses.some(
(loss) => loss.path === '/edges/0/routingPoints',
)) {
throw new Error('Ambiguous geometry was not refused');
}
const dropped = migrateIR(ambiguousGraphIR1, { ambiguousGeometry: 'drop' });
if (!dropped.success || !dropped.migrated) {
throw new Error(dropped.errors.join('\n'));
}
if (!dropped.losses.some((loss) =>
loss.path === '/edges/0/routingPoints' && loss.field === 'routingPoints')) {
throw new Error('Explicit migration loss was not attributed');
}
for (const loss of dropped.losses) console.warn(loss.path, loss.reason);
const droppedUpgrade = migrateGraphIR2To3(dropped.migrated);
if (!droppedUpgrade.success || !droppedUpgrade.migrated) {
throw new Error(droppedUpgrade.errors.join('\n'));
}GraphIR 1 routingPoints are ambiguous: points do not say whether their coordinates are absolute, relative, or anchored. Migration therefore refuses them by default. If discarding that geometry is acceptable, opt in explicitly with ambiguousGeometry: 'drop' and inspect the returned losses before using the migrated graph.
GraphIR 2 replaces routingPoints with authored routeIntent, narrows GraphIR.version to 2.0.0, and removes LayoutOptions.algorithmOptions. Migration does not invent route intent or algorithm-specific meaning that was not present in the source. Keep the migration at an explicit trust boundary; do not cast a GraphIR 1 object to GraphIR 2.
GraphIR 2 to GraphIR 3
Use migrateGraphIR2To3 for every GraphIR 2 value. The result records stable, path-specific changes, losses, and diagnostics. It maps recognized notation profiles, legacy arrows, unambiguous classifier members, and sequence order; ambiguous members or invalid references fail rather than being guessed. Do not change only the version field or cast a GraphIR 2 object to GraphIR 3.
Compatibility boundary
Published Coral 0.2.5/core 0.2.1/schema 2 is the comparison baseline. The reviewed core 0.2.2/schema 3 transition is the only approved GraphIR public transition for Coral 0.2.6; unrelated Coral APIs remain compatible.