Files
Jonathan Boniface 9e503885cc ALZ-F01 Discovery: package step, value scorecard, application grouping, cases
- New cp1-discovery-package-agent (ADR 0020): one package per reviewed run, every part
  hashed (sha256 over canonical JSON), with a manifest and a value scorecard.
- Applications grouped CMDB -> tag -> resource group with a judged model fallback (ADR 0021):
  CMDB 0.7.0 carries ownership, dependency mapping 0.6.0 groups, report 0.9.0 shows them.
- Critic 0.6.1 accepts the producers' enums; build_workflow.py refuses a consumer enum
  narrower than its producer's.
- Code hooks, sub-agents and tests for the inventory, CMDB, dependency, planner and critic
  agents; the report and Well-Architected review agents; ADRs 0012-0021.
- Workflow cases with value bars and run limits; run evaluation and usage collection scripts;
  the run context template and the field-by-field review for ADR 0016.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 22:13:25 +00:00

42 lines
1.6 KiB
Python

"""A live run's inventory is built in batches from pre_process (ADR 0015); the sample estate keeps the agent loop."""
import json
import os
from pathlib import Path
from typing import Any, Optional
import jsonschema
import structlog
from kyndryl_agent_runtime import ask_sub_agent
from kyndryl_agent_runtime.request_cycle import Reply
from app import inventory
logger = structlog.get_logger(__name__)
OUTPUT_SCHEMA = json.loads((Path(__file__).resolve().parents[1] / "schemas" / "output.json").read_text())
def _setting(name: str, default: int) -> int:
try:
return max(1, int(os.getenv(name, default)))
except ValueError:
return default
async def pre_process(payload: dict) -> Optional[Any]:
if payload.get("provider", "sample") == "sample":
return None # the Meridian sample estate: prompt.md and the alz-inventory tools, unchanged
async def ask(prompt: str) -> str:
return await ask_sub_agent("normalise_batch", prompt)
result = await inventory.build(
payload, ask,
batch_size=_setting("INVENTORY_BATCH_SIZE", 20),
max_tries=_setting("INVENTORY_MAX_TRIES", 3),
log=lambda event, **fields: logger.info(event, **fields),
)
errors = sorted(jsonschema.Draft202012Validator(OUTPUT_SCHEMA).iter_errors(result), key=lambda e: list(e.path))
if errors: # a Reply can't be repaired by the output contract, so a broken one fails the step here
raise inventory.InventoryFailed(f"the inventory broke its output schema: {errors[0].message}")
return Reply(json.dumps(result, ensure_ascii=False))