Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Graph Engineering & Self-Improvement

The primary architectural standard for this framework is now graph engineering: one explicit, declarative engagement graph defines the topology, state channels, reducers, conditional routers, bounded loops, and memory boundaries for every runtime. The source of truth is graph/redteam.graph.json, validated against schemas/graph.schema.json by tools/graph/validate-graph.mjs.

Why graph engineering

The graph makes orchestration inspectable instead of implicit prompt choreography:

Canonical topology

The topology is:

  1. START -> validate_scope — the subscription, scope, engagement mode, and read-only role posture are validated before any Azure access.

  2. memory_load — prior methodology memory is loaded as read-only context.

  3. preflight_inventory — the Inventory & Scope agent performs sequential permission checks and resource enumeration.

  4. plan_specialists -> run_specialist — a LangGraph-style Send fan-out maps over the in-scope read-only roster and dispatches one specialist worker per domain in parallel.

  5. collect_raw — raw specialist outputs fan back in through a deterministic merge_findings reduce.

  6. evaluate — the evaluator-optimizer loop head runs deterministic checks plus a critic score over candidate findings.

  7. route_after_evaluate — if revision < max_revisions and quality is below quality_threshold, the graph reflects back to plan_specialists; otherwise it proceeds.

  8. judge — an Agent-as-a-Judge gate re-checks candidate findings using targeted read-only evidence queries and suppresses false positives into methodology memory.

  9. authorize_active / route_active — a human-in-the-loop interrupt gates the optional active lanes. Read-only or rejected runs route straight to correlation.

  10. correlate -> report — confirmed findings are correlated into RBAC and attack paths, then rendered into deliverables.

  11. reflexion_debrief -> END — the run records an inert episode. Stable lessons are promoted only after matching evidence from at least two distinct runs for the same agent.

State channels and reducers

The graph state follows a LangGraph-style channel model. Concurrent writes are safe because each channel declares its reducer in the graph contract.

ChannelTypeReducerRole
scopeobjectlastValidated subscription, mode, domain, exclusion, and read-only role context.
memoryobjectlastMethodology memory loaded from prior runs.
inventory_refstringlastPath to the preflight resource inventory.
raw_findingsarrayappendPer-specialist JSONL outputs accumulated by Send fan-in.
candidate_findingsarraymerge_findingsDeterministically deduped findings before critique and judge.
critiqueobjectlastEvaluator quality score and notes that drive reflection.
revisionnumberlastBounded reflection iteration counter.
confirmed_findingsarraymerge_findingsFindings promoted by the false-positive judge.
attack_pathsarrayappendCross-domain authorization and attack-path chains.
report_refsarrayappendRendered deliverable paths.
approvedboolean/nulllastHuman decision at the gated active-lane interrupt.

Self-improving loops

The graph deliberately borrows from prior art in self-improving agents while excluding unsafe runtime self-modification:

AEF-compatible learning contract

The loop adapts the safe reflection-and-memory architecture from the read-only aef-core snapshot at commit 48ee1ef7cd9f2cc91762f4b4c08150d954d443ec. The source checkout is not a runtime dependency and was not modified. AEF’s disabled runtime code-evolution path is deliberately excluded. The imported contract contributes four controls: inert candidates, independent run attribution, per-agent consolidation, and auditable promotion or rollback.

Memory firewall: the immutable boundary

The one immutable boundary is the read-only enforcement system. Learning may write only memory/methodology/; it may not modify the guard core, egress allowlist, cluster allowlist, read-only role requirements, or anything under guardrails/**. The graph schema describes this as a memory-write target, and tools/graph/validate-graph.mjs enforces structural and referential integrity, including the memory firewall.

Unsafe runtime self-modification is intentionally excluded: no runtime code execution, no tool creation, and no self-rewriting of the guard. Methodology memory can change how agents investigate and critique; it cannot change what they are allowed to do.

One graph, two engines

The same graph/redteam.graph.json drives two execution models:

  1. Dependency-free Node runnertools/graph/run-graph.mjs executes the graph inside the GitHub Copilot CLI, Claude Code, OpenAI Codex CLI, and Cursor runtimes. The core stays zero-dependency and uses the durable JSONL checkpointer in tools/orchestration/manifest.mjs.

  2. First-class LangGraph targetintegrations/langgraph/ compiles the same JSON graph into a Python StateGraph, using LangGraph concepts such as Send, reducers, checkpointers, interrupts, and Store-style memory while reusing the same read-only guard through a subprocess bridge. Its dependencies are isolated from the Node core.

Prior art and ecosystem

This architecture is inspired by:

The framework adapts those ideas to a red-team setting by keeping the learning surface narrow and the enforcement surface deterministic, fail-closed, and shared by every runtime.