Azure BGP Route Leak Detection
When to Use
- Analyze BGP routing configurations in Azure Virtual WAN
- Detect route oscillation and valley-free routing violations
- Evaluate which solutions resolve BGP routing issues
Execution Discipline
Execution Discipline
- Follow any task-specific interaction or tool/action contract exactly. If the environment requires a specific wrapper, literal action syntax, tool name, file-path restriction, or exact completion signal, use that exact format for every step.
- Before the first action, re-check the task prompt for execution constraints, allowed paths, sequencing rules, and termination requirements.
- Keep writes inside explicitly allowed locations; prefer direct commands or in-memory JSON processing over creating helper scripts, scratch files, or unnecessary intermediate artifacts.
- If the task specifies an exact completion token, emit that exact token and nothing else after all files are written and validated.
Key Concepts
- Oscillation: Routing preference cycle causing unstable routes
- Route leak: Hub advertising routes to another hub via Virtual WAN (violates valley-free)
- Valley-free routing: Customer→Provider→Peer patterns, no Provider→Peer→Customer
- AS path preferences: local_pref determines routing priority
- Treat AS relationships and advertisement paths as unknown unless explicit in the input files. Do not assume a hub is a provider, peer, or customer, or that a route leak exists, without direct evidence from the loaded JSON.
- Treat provider/peer/customer roles as data-driven from
local_pref.jsonor other explicit inputs, not as defaults implied by Azure Virtual WAN terminology.
Input Files
/app/data/route.json: Route advertised from vnet/app/data/preferences.json: Routing preferences between hubs/app/data/local_pref.json: Relationship type weights/app/data/possible_solutions.json: Solutions to evaluate
- Verify the actual filenames present in
/app/databefore reading them. If a listed filename differs from what is on disk, use the observed path and reconcile the mismatch before analysis. - Validate that all required inputs are present, readable, and fully loaded before analysis. If a file is missing, renamed, truncated, or partially read, resolve that first and re-read the full content before using it.
- Inspect each JSON file's actual schema before writing detection logic. Normalize once into simple internal forms and use those forms consistently.
preferences.jsonmay use ASN string keys with nested objects such as{ "65002": {"prefer_via": 65003} }; normalize this to a plain map like65002 -> 65003before cycle detection.- Convert ASN identifiers to one type consistently (prefer integers in memory) so comparisons and output are stable.
- Treat only the provided input files as the evidence base. Do not assume AS roles, hub/provider/peer/customer relationships, Azure-owned ASNs, WAN ASN values, or leak paths unless they are directly supported by the inputs.
- Treat
possible_solutions.jsonas authoritative: do not score, name, number, or infer any solution unless it appears in the fully loaded file.
- After listing
/app/data, build your read plan from the observed filenames only. If an expected file is misspelled, renamed, or differs from the prompt/skill, confirm which on-disk file supplies each required input and then use that verified path consistently. - If any file read is truncated, incomplete, malformed, cut off mid-object/array/string, or shown only as partial command output, treat that as a hard stop: re-read until the full valid JSON content is available before analysis.
- Do not enumerate or evaluate candidate solutions until
possible_solutions.jsonhas been fully read, parsed successfully, and inspected end-to-end, including the complete list and full text of every solution. - Record the exact set of loaded solution items first; later
solution_resultsmust map only to that confirmed set. - Do not rely on delegated or opaque subagent judgments for oscillation detection, leak detection, or per-solution outcomes. Perform and verify the core reasoning directly from the loaded inputs.
- If complete recovery of a required input is not possible, stop analysis rather than fabricate a complete report from incomplete evidence.
Required Analysis Workflow
- Do not create auxiliary scripts or write intermediate files unless the task explicitly allows them; only write the required output file(s).
- If any loaded input or produced report appears partial or malformed at any point, do not continue from it; re-read, regenerate, or rewrite it and validate the full contents first.
Required Analysis Workflow
- Read all four input files completely before deciding anything.
- Normalize the parsed JSON into stable internal structures before analysis.
- Build preference, relationship, and advertisement relationships from the input data, not from assumptions about Azure topology.
- Detect baseline issues from the provided evidence only:
- determine whether a directed preference cycle creates oscillation
- determine whether any advertised path violates valley-free routing
- If the inputs do not show enough topology, relationship, or advertisement data to prove a specific route leak, set
route_leak_detectedtofalseandroute_leaksto[]rather than guessing. - Evaluate every entry in
possible_solutions.jsonseparately by recomputing whether the demonstrated cycle and prohibited advertisement would still exist after applying that solution's stated effect. - Mark
oscillation_resolvedtrue only if the solution breaks the observed preference cycle, and markroute_leak_resolvedtrue only if it prevents the specific prohibited advertisement path evidenced in the inputs. - Do not classify solutions by keyword matching, generic networking intuition, or unsupported assumptions.
- Produce exactly one
solution_resultsentry per input solution and no extra entries. - Only after completing the per-solution evaluation, write
/app/output/oscillation_report.jsonand validate it.
Output Format
JSON at /app/output/oscillation_report.json:
{
"oscillation_detected": true/false,
"oscillation_cycle": [AS1, AS2],
"affected_ases": [AS_numbers],
"route_leak_detected": true/false,
"route_leaks": [{"leaker_as": N, "source_as": M, "destination_as": K, ...}],
"solution_results": {"solution_name": {"oscillation_resolved": bool, "route_leak_resolved": bool}}
}
- Match the schema exactly and save only the fields shown above.
- Do not add extra top-level fields such as
summaryorexplanationunless explicitly requested. - In
solution_results, each solution value must contain onlyoscillation_resolvedandroute_leak_resolved. - Keep
route_leaksentries to the requested structure such asleaker_as,source_as, anddestination_as; do not add narrative fields such asdescriptionunless requested. - If no supported oscillation cycle is found, use
"oscillation_detected": falseand an emptyoscillation_cycle. - If no supported leak instance is established from the inputs, use
"route_leak_detected": falseand an emptyroute_leaksarray. - Populate output fields only from observable input data and directly derivable routing rules; do not infer unsupported topology details or remediation effects.
- After writing
/app/output/oscillation_report.json, read back or parse the entire file to confirm it is complete (not truncated), valid JSON, contains all required top-level keys, contains no extra top-level fields, and includes exactly onesolution_resultsentry for every candidate inpossible_solutions.json. - Do not treat a partial terminal display as sufficient verification; if the readback cuts off mid-file or mid-field, perform another full check before finishing.
- Before saving, compare the output object against the required schema and remove any unsupported or unrequested fields.
- Do not add top-level fields like
summary, per-solution fields likereasonorexplanation, or narrative fields insideroute_leaksunless explicitly requested. - When source inputs use different field names for leak events, transform them into the required report keys such as
leaker_as,source_as, anddestination_asbefore saving. - Validate that every
solution_resultsentry has exactly this shape:"solution_name": {"oscillation_resolved": bool, "route_leak_resolved": bool}; do not add fields such asstatus,reason,summary, orinvalid. - Before finalizing, cross-check that the keys in
solution_resultsmatch the exact set and count of solutions actually loaded frompossible_solutions.json, with no omissions, duplicates, or extra inferred entries. - If
possible_solutions.jsonwas re-read due to truncation or schema uncertainty, rebuildsolution_resultsfrom the final confirmed file contents before saving. - Write the report atomically as complete JSON; if the first write or read-back shows truncated, partial, or invalid JSON, rewrite
/app/output/oscillation_report.jsoncompletely and re-validate before finishing. - Return only the required artifact and any task-required completion signal.
Tips
- Detect oscillation from the actual preference graph between hubs/ASes; report a cycle only if the preferences form a directed loop.
- Detect a route leak only from actual advertisement paths and relationship data that show a valley-free violation, especially hub-to-hub re-advertisement via Virtual WAN.
- Mark
oscillation_resolvedtrue only if the solution removes at least one edge or preference needed for the demonstrated loop. - Mark
route_leak_resolvedtrue only if the solution prevents the specific prohibited advertisement path evidenced in the inputs. - Evaluate each proposed solution from its network effect on the given topology and preferences, not by keyword or substring matching on the solution name/text.
- If evidence is insufficient to prove a specific leak, AS relationship, or solution outcome, stay conservative rather than filling gaps with assumptions.
- Verify
solution_resultscovers every solution frompossible_solutions.json; no omissions, duplicates, or guesses from incomplete solution text. - Before finalizing, cross-check that every reported oscillation or leak claim is traceable to the observed preference graph or route propagation path in the input files.
- Treat completeness as a gate: do not start detection or solution scoring until every required file has been fully read and successfully parsed.
- A directed preference cycle is enough for oscillation detection, but it is not enough by itself for
route_leak_detected = true. - When
preferences.jsonalready gives direct next-hop preferences, check that graph first; a simple 2-node or longer directed cycle is enough to prove oscillation without simulating BGP dynamics. - If a route record explicitly states relationship labels for where the route was learned and where it was advertised, use those labels directly to test valley-free export rules instead of inferring missing relationships from topology names.
- Normalize once, then keep all detection and evaluation logic operating on that normalized representation; do not pass raw nested preference objects into cycle logic.
- For each solution marked effective, be able to name the specific cycle edge it breaks or the specific prohibited advertisement it blocks from the observed inputs.
- If any file view is truncated, incomplete, or suspiciously partial, stop and re-read the full file before claiming complete topology facts or evaluating every solution.
- Keep the reasoning auditable from observed data; do not copy in unverified classifications from a subagent, summary, or truncated intermediate output.
- Before finishing, confirm both the saved output file and any task-specific final response or completion format are satisfied exactly.