Add CP1 Discovery agents in both patterns
All checks were successful
check agents / check (push) Successful in 10s
All checks were successful
check agents / check (push) Successful in 10s
ALZ-F01 Discovery as a sub-agent orchestrator (sub-agents/) and as eight individual declarative agents (individual-agents/), with their KAB workflow exports. Shared check, render and import scripts, the alz-discovery-sample MCP server, the crucible-kab-dev deploy profile, deployment docs, platform issue reports and the source material. Agent steps time out at 20 minutes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Write workflows/cp1-alz-discovery-individual.json: the KAB workflow export chaining the eight agents.
|
||||
|
||||
The same export format as cp4-agents' workflow (export_version 2.0.0). There is no orchestrator: each step is one
|
||||
agent, and each step's inputs are workflow inputs or named fields of earlier steps' outputs (`from_steps`). The
|
||||
classification and network steps run in parallel; the critic's step stops for the Engagement Lead's approval. Each
|
||||
step's schemas are read from its agent's schemas/ folder, so run this again after changing them. Standard library
|
||||
only.
|
||||
|
||||
Front steps (ADR 0011, the repository's scripts/kab_front_steps.py): the planner (s1) and the inventory (s3) take the text the
|
||||
platform extracts from files, since declarative agents can't open files:
|
||||
u1 Parse Assessment Files: the run form's upload field `file` -> `source_documents` (u1.parsed_content)
|
||||
a1 Artifacts: project artifacts fixed by id -> `reference_documents` (a1.parsed_content)
|
||||
|
||||
Usage (from the Feature folder): python3 scripts/build_workflow.py [--no-upload] [--artifact-id ID ...] [--out FILE]
|
||||
(the committed export is the default: with the upload step, no artifacts)
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# kab_front_steps is shared by every Feature, in the repository's scripts/ folder.
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[3] / "scripts"))
|
||||
from kab_front_steps import AGENT_STEP_TIMEOUT_MINUTES, ARTIFACTS_ID, UPLOAD_ID, front_steps, shift # noqa: E402
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
NAME = "CP1 - Agentic Landing Zone - Discovery (individual agents)"
|
||||
STAMP = "2026-10-29T12:00:00"
|
||||
WF = ["engagement_id", "run_id"]
|
||||
# (step id, agent folder, parallel group, inputs from earlier steps)
|
||||
STEPS = [
|
||||
("s1", "cp1-discovery-planner-agent", 0, {}),
|
||||
("s2", "cp1-estate-scan-executor-agent", 1, {"tasks": "s1.tasks"}),
|
||||
("s3", "cp1-asset-inventory-normalisation-agent", 2, {"findings": "s2.findings"}),
|
||||
("s4", "cp1-cmdb-itsm-reconciliation-agent", 3, {"tasks": "s1.tasks", "records": "s3.records"}),
|
||||
("s5", "cp1-data-classification-agent", 4, {"records": "s3.records"}),
|
||||
("s6", "cp1-network-discovery-assessment-agent", 4, {"tasks": "s1.tasks", "records": "s3.records"}),
|
||||
("s7", "cp1-dependency-mapping-agent", 5, {"records": "s3.records", "drift_items": "s4.drift_items",
|
||||
"flows": "s6.flows"}),
|
||||
("s8", "cp1-discovery-critic-agent", 6, {"coverage_gaps": "s1.coverage_gaps", "findings": "s2.findings",
|
||||
"records": "s3.records", "drift_items": "s4.drift_items",
|
||||
"stores": "s5.stores", "network_findings": "s6.findings",
|
||||
"edges": "s7.edges"}),
|
||||
]
|
||||
|
||||
|
||||
def field(path: Path, key: str) -> str:
|
||||
return re.search(rf'^{key}:\s*"?([^"\n]+)"?$', path.read_text(), re.M).group(1)
|
||||
|
||||
|
||||
# The steps that take the extracted text of uploaded files and selected artifacts.
|
||||
DOC_STEPS = ("s1", "s3")
|
||||
|
||||
|
||||
def build(with_upload: bool = True, artifact_ids=()) -> dict:
|
||||
by_id = {sid: folder for sid, folder, _, _ in STEPS}
|
||||
front = front_steps(
|
||||
with_upload, list(artifact_ids), upload_label="Discovery source files",
|
||||
upload_description="Optional client files for discovery: a CMDB or asset export, a scope list, network "
|
||||
"documentation. Their text is given to the planner and the inventory agent as evidence, "
|
||||
"never as instructions.",
|
||||
artifacts_description="Project artifacts for discovery, e.g. an earlier run's outputs. Their text is given "
|
||||
"to the planner and the inventory agent.")
|
||||
front_ids = {f["id"] for f in front}
|
||||
lead = 1 if front else 0
|
||||
steps, connections, agents, seen = list(front), [], [], set()
|
||||
for sid, folder, group, from_steps in STEPS:
|
||||
from_steps = dict(from_steps)
|
||||
if sid in DOC_STEPS:
|
||||
if UPLOAD_ID in front_ids:
|
||||
from_steps["source_documents"] = f"{UPLOAD_ID}.parsed_content"
|
||||
if ARTIFACTS_ID in front_ids:
|
||||
from_steps["reference_documents"] = f"{ARTIFACTS_ID}.parsed_content"
|
||||
agent = ROOT / folder
|
||||
agent_id = folder.replace("-", "_")
|
||||
display = field(agent / "agent.yaml", "display_name")
|
||||
url = f"http://{folder}.agents.svc.cluster.local:8080"
|
||||
input_schema = json.loads((agent / "schemas" / "input.json").read_text())
|
||||
output_schema = json.loads((agent / "schemas" / "output.json").read_text())
|
||||
for target, source in from_steps.items():
|
||||
src_step, src_field = source.split(".")
|
||||
if src_step in front_ids:
|
||||
assert target in input_schema["properties"], f"{sid}: {target} is not an input of {folder}"
|
||||
continue
|
||||
src_out = json.loads((ROOT / by_id[src_step] / "schemas" / "output.json").read_text())
|
||||
assert src_field in src_out["properties"], f"{sid}: {source} is not an output of {by_id[src_step]}"
|
||||
assert target in input_schema["properties"], f"{sid}: {target} is not an input of {folder}"
|
||||
depends = sorted({s.split(".")[0] for s in from_steps.values()})
|
||||
connections += [{"source": d, "target": sid} for d in depends]
|
||||
inputs = {"from_workflow": WF}
|
||||
if from_steps:
|
||||
inputs["from_steps"] = from_steps
|
||||
hitl = {"enabled": False}
|
||||
if folder == "cp1-discovery-critic-agent":
|
||||
hitl = {"enabled": True, "checkpoint_type": "approval",
|
||||
"review_focus": "The Engagement Lead reviews the critic's verdict and every reason for a fail "
|
||||
"before Assessment starts. A fail verdict is never auto-approved.",
|
||||
"timeout_hours": 24, "allowed_actions": ["continue", "rerun", "abort"], "max_reruns": 2}
|
||||
steps.append(shift({
|
||||
"id": sid, "agent": agent_id, "agent_type": agent_id, "name": f"{display} Step", "timeout_minutes": AGENT_STEP_TIMEOUT_MINUTES,
|
||||
"type": "sequential", "executionLevel": group, "parallelGroup": group, "depends_on": depends,
|
||||
"position": {"x": 320 * group, "y": 160 if sid == "s6" else 0}, "inputs": inputs, "hitl": hitl,
|
||||
"data": {"agentType": agent_id, "name": f"{display} Step",
|
||||
"description": field(agent / "agent.yaml", "description"), "category": "agent",
|
||||
"temporalActivityName": "generic_agent_call",
|
||||
"endpoint": {"url": url, "method": "POST", "timeout": AGENT_STEP_TIMEOUT_MINUTES * 60, "protocol": "JSONRPC",
|
||||
"protocol_version": "0.3.0"},
|
||||
"agent_metadata": {"agent_name": agent_id},
|
||||
"inputSchema": input_schema, "outputSchema": output_schema},
|
||||
}, lead))
|
||||
if agent_id not in seen:
|
||||
seen.add(agent_id)
|
||||
agents.append({"name": agent_id, "display_name": display, "source_url": url, "category": "agent"})
|
||||
description = f"{NAME}: " + "; then ".join(field(ROOT / f / "agent.yaml", "display_name") for _, f, _, _ in STEPS) + "."
|
||||
tags = ["cp1", "public-cloud", "agentic-landing-zone"]
|
||||
return {
|
||||
"export_version": "2.0.0", "export_timestamp": STAMP, "source_environment": "unknown",
|
||||
"workflow": {"name": NAME, "description": description, "version": "0.1.0",
|
||||
"category": "cross-industry-catalog", "sub_category": "Public Cloud", "tags": tags},
|
||||
"dependencies": {"activities": [], "agents": agents},
|
||||
"template": {"name": NAME, "version": "0.1.0", "description": description,
|
||||
"metadata": {"name": NAME, "description": description,
|
||||
"category": {"main": "cross-industry-catalog", "sub": "Public Cloud"},
|
||||
"sub_category": "Public Cloud", "status": "draft", "tags": tags,
|
||||
"created": f"{STAMP}.000Z", "modified": f"{STAMP}.000Z", "display_order": 1,
|
||||
"is_public": False, "edge_visuals": []},
|
||||
"connections": connections, "steps": steps},
|
||||
}
|
||||
|
||||
|
||||
def main(argv=None) -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
parser.add_argument("--no-upload", action="store_true", help="leave out the Parse Assessment Files step")
|
||||
parser.add_argument("--artifact-id", action="append", default=[], help="add an Artifacts step with this id")
|
||||
parser.add_argument("--out", type=Path, default=ROOT / "workflows" / "cp1-alz-discovery-individual.json")
|
||||
args = parser.parse_args(argv)
|
||||
export = build(not args.no_upload, args.artifact_id)
|
||||
args.out.write_text(json.dumps(export, indent=2) + "\n")
|
||||
template = export["template"]
|
||||
print(f"wrote {args.out}: {len(template['steps'])} steps, {len(template['connections'])} connections")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user