twining_trace
Trace decision dependencies upstream to identify prerequisites or downstream to see impacts. Maps relationships in development workflows using BFS with cycle protection.
Instructions
Trace a decision's dependency chain upstream (what it depends on) and/or downstream (what depends on it). Uses BFS with cycle protection.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| decision_id | Yes | ID of the decision to trace | |
| direction | No | Direction to trace (default: "both") |
Implementation Reference
- src/tools/decision-tools.ts:144-155 (handler)The MCP tool handler for "twining_trace" which calls the engine's trace method and handles errors.
async (args) => { try { const result = await engine.trace(args.decision_id, args.direction); return toolResult(result); } catch (e) { if (e instanceof TwiningError) { return toolError(e.message, e.code); } return toolError( e instanceof Error ? e.message : "Unknown error", "INTERNAL_ERROR", ); - src/engine/decisions.ts:403-406 (helper)The core implementation of the trace logic within the decision engine.
async trace( decisionId: string, direction: "upstream" | "downstream" | "both" = "both", ): Promise<{ chain: TraceEntry[] }> { - src/tools/decision-tools.ts:131-143 (registration)Registration of the "twining_trace" tool including its input schema and description.
server.registerTool( "twining_trace", { description: "Trace a decision's dependency chain upstream (what it depends on) and/or downstream (what depends on it). Uses BFS with cycle protection.", inputSchema: { decision_id: z.string().describe("ID of the decision to trace"), direction: z .enum(["upstream", "downstream", "both"]) .optional() .describe('Direction to trace (default: "both")'), }, },