decomposer: generate deliverable files for Inspect the single_agent template and target repository conventions to identify the required project structure, configuration, interfaces, and implementation patterns for the application landing zone agent.; Define the application landing zone agent's behavior, input and output contracts, document-generation workflow, and architecture-diagram requirements using the extracted template conventions.; Validate the implemented application_landing_zone_agent by running repository tests and checking the TSD document generation, draw.io diagram generation, agent packaging, configuration, and committed implementation against the defined contracts.; Commit and push the validated application_landing_zone_agent implementation to the target repository.
This commit is contained in:
4
src/landing_zone_agent/__init__.py
Normal file
4
src/landing_zone_agent/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
"""Application landing zone agent package."""
|
||||
from .generator import generate
|
||||
|
||||
__all__ = ["generate"]
|
||||
21
src/landing_zone_agent/cli.py
Normal file
21
src/landing_zone_agent/cli.py
Normal file
@@ -0,0 +1,21 @@
|
||||
"""Command-line entrypoint."""
|
||||
import argparse, json
|
||||
from pathlib import Path
|
||||
from .generator import generate
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
parser = argparse.ArgumentParser(description="Generate TSD and draw.io landing-zone artifacts")
|
||||
parser.add_argument("--requirements", required=True)
|
||||
parser.add_argument("--output-dir", required=True)
|
||||
args = parser.parse_args(argv)
|
||||
with open(args.requirements, encoding="utf-8") as stream:
|
||||
result = generate(json.load(stream))
|
||||
output = Path(args.output_dir); output.mkdir(parents=True, exist_ok=True)
|
||||
(output / "tsd.md").write_text(result["tsd"], encoding="utf-8")
|
||||
(output / "architecture.drawio").write_text(result["drawio"], encoding="utf-8")
|
||||
(output / "manifest.json").write_text(json.dumps(result["manifest"], indent=2), encoding="utf-8")
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
9
src/landing_zone_agent/config.py
Normal file
9
src/landing_zone_agent/config.py
Normal file
@@ -0,0 +1,9 @@
|
||||
"""Configuration loading with explicit, repository-relative defaults."""
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def load_config(path=None):
|
||||
path = Path(path or "config/agent.json")
|
||||
with path.open(encoding="utf-8") as stream:
|
||||
return json.load(stream)
|
||||
73
src/landing_zone_agent/generator.py
Normal file
73
src/landing_zone_agent/generator.py
Normal file
@@ -0,0 +1,73 @@
|
||||
"""Deterministic TSD and draw.io artifact generation."""
|
||||
from html import escape
|
||||
from datetime import datetime, timezone
|
||||
from .validation import validate_requirements, validate_drawio
|
||||
|
||||
|
||||
def _items(values):
|
||||
return "\n".join(f"- {value}" for value in values) if values else "- None specified"
|
||||
|
||||
|
||||
def _drawio(req):
|
||||
name = escape(req["application_name"])
|
||||
components = req.get("components") or ["application service"]
|
||||
cells = [('<mxCell id="0"/>', '<mxCell id="1" parent="0"/>')]
|
||||
cells = [f'<mxCell id="{i+2}" value="{escape(str(value))}" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1"><mxGeometry x="{80 + (i%3)*220}" y="{100 + (i//3)*120}" width="180" height="60" as="geometry"/></mxCell>' for i, value in enumerate(["Users", name] + components)]
|
||||
edges = []
|
||||
for i in range(2, len(cells)+1):
|
||||
edges.append(f'<mxCell id="e{i}" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;" edge="1" parent="1" source="{i}" target="{i+1}"><mxGeometry relative="1" as="geometry"/></mxCell>')
|
||||
body = '<mxCell id="0"/><mxCell id="1" parent="0"/>' + ''.join(cells + edges)
|
||||
return f'<mxfile host="app.diagrams.net" modified="{datetime.now(timezone.utc).isoformat()}" agent="application-landing-zone-agent"><diagram name="Application Landing Zone"><mxGraphModel><root>{body}</root></mxGraphModel></diagram></mxfile>'
|
||||
|
||||
|
||||
def generate(requirements):
|
||||
validate_requirements(requirements)
|
||||
name = requirements["application_name"]
|
||||
components = requirements.get("components") or ["application service"]
|
||||
integrations = requirements.get("integrations") or []
|
||||
constraints = requirements.get("constraints") or []
|
||||
tsd = f'''# Technical Solution Design: {name}
|
||||
|
||||
## 1. Executive summary
|
||||
{requirements["business_context"]}
|
||||
|
||||
## 2. Scope and assumptions
|
||||
- Data classification: **{requirements["data_classification"]}**
|
||||
- Availability target: **{requirements["availability_target"]}**
|
||||
- Environments: {", ".join(requirements["environments"])}
|
||||
- This baseline assumes managed identity, encrypted transport/storage, and centralized observability.
|
||||
|
||||
## 3. Logical architecture
|
||||
The request path is Users → application boundary → service components → data and external integrations. The editable companion diagram is `architecture.drawio`.
|
||||
|
||||
### Components
|
||||
{_items(components)}
|
||||
|
||||
### Integrations
|
||||
{_items(integrations)}
|
||||
|
||||
## 4. Environment and landing-zone design
|
||||
- Separate accounts/subscriptions/projects per environment where supported.
|
||||
- Private network segments for services and data; ingress is restricted to approved entry points.
|
||||
- Infrastructure is provisioned through repeatable, reviewed automation.
|
||||
|
||||
## 5. Security, resilience, and operations
|
||||
- Apply least privilege, secrets management, encryption in transit and at rest, and audit trails.
|
||||
- Define backup/restore objectives and test them before production release.
|
||||
- Monitor availability, latency, errors, capacity, security events, and deployment health.
|
||||
- Use health checks, autoscaling boundaries, and tested rollback procedures.
|
||||
|
||||
## 6. Constraints and decisions to confirm
|
||||
{_items(constraints)}
|
||||
- Confirm cloud/provider, RTO/RPO, retention, network connectivity, identity provider, and sizing during architecture review.
|
||||
|
||||
## 7. Delivery acceptance criteria
|
||||
- [ ] Threat model and data-flow review completed.
|
||||
- [ ] Non-production and production isolation verified.
|
||||
- [ ] Observability, backup, restore, and disaster-recovery tests recorded.
|
||||
- [ ] Diagram and assumptions approved by service owners.
|
||||
'''
|
||||
diagram = _drawio(requirements)
|
||||
if not validate_drawio(diagram):
|
||||
raise RuntimeError("generated diagram failed draw.io contract")
|
||||
return {"tsd": tsd, "drawio": diagram, "manifest": {"agent": "application_landing_zone_agent", "generated_at": datetime.now(timezone.utc).isoformat(), "assumptions": ["managed identity", "encrypted transport/storage", "central observability"], "validation": {"requirements": True, "drawio": True}}}
|
||||
21
src/landing_zone_agent/validation.py
Normal file
21
src/landing_zone_agent/validation.py
Normal file
@@ -0,0 +1,21 @@
|
||||
"""Input and output contract validation."""
|
||||
REQUIRED = ("application_name", "business_context", "environments", "data_classification", "availability_target")
|
||||
|
||||
|
||||
def validate_requirements(data):
|
||||
if not isinstance(data, dict):
|
||||
raise ValueError("requirements must be a JSON object")
|
||||
missing = [key for key in REQUIRED if not data.get(key)]
|
||||
if missing:
|
||||
raise ValueError("missing required fields: " + ", ".join(missing))
|
||||
if not isinstance(data["environments"], list) or not data["environments"]:
|
||||
raise ValueError("environments must be a non-empty array")
|
||||
for key in ("components", "integrations", "constraints"):
|
||||
if key in data and not isinstance(data[key], list):
|
||||
raise ValueError(f"{key} must be an array")
|
||||
return True
|
||||
|
||||
|
||||
def validate_drawio(xml):
|
||||
required = ("<mxfile", "<diagram", "<mxGraphModel", "<mxCell", "</mxfile>")
|
||||
return all(token in xml for token in required)
|
||||
Reference in New Issue
Block a user