Files
cp1-agents/individual-agents/ALZ-F02: Assessment & Disposition Workflow Agent/scripts/package_schemas.py
Jonathan Boniface 66c32745aa
Some checks failed
check agents / check (push) Failing after 14s
F02: Assessment report and package (ADR 0014, 0015); register agents in KAB
- Report (cp1-assessment-report-agent 0.2.0, step s7): a model writes the
  Assessment report from facts worked out in code (register, gaps, scorecard,
  rule traces, checks, and what each application is from the Discovery
  package); code sets the verdict and renders the pages. The
  disposition_signoff review point moves from the critic to the report.
- Package (cp1-assessment-package-agent 0.1.1, step s8): after sign-off, every
  step's output in one package, with a register, a gaps register, the
  sign-off record, lineage and a sha256 per part, in code. Page step s9.
- scripts/kab_register_agents.py: registers deployed agents in KAB's agent
  catalog (an in-place workflow update doesn't).
- Runs exec_1b1257380df7 (014) and exec_374d5d577077 (015) completed on
  crucible-kab-dev: critic pass, report figures all in its facts, package
  complete with every digest recomputing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 20:19:10 +00:00

52 lines
3.3 KiB
Python

#!/usr/bin/env python3
"""Write the input schemas of the package and report agents from cp1-assessment-package-agent/app/package.py INPUTS
(ADR 0014, ADR 0015), each input typed as its producer declares it, plus null, with no enum. Run after changing INPUTS.
Usage (from the Feature folder): python3 scripts/package_schemas.py
"""
import json
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "cp1-assessment-package-agent"))
from app import package # noqa: E402
PRODUCER = {"discovery": "cp1-assessment-intake-agent", "plan": "cp1-assessment-planner-agent",
"profiles": "cp1-cloud-readiness-profiler-agent", "risk": "cp1-migration-risk-scorer-agent",
"security": "cp1-security-posture-assessment-agent", "dispositions": "cp1-disposition-tco-agent",
"critic": "cp1-assessment-critic-agent", "report": "cp1-assessment-report-agent"}
RUN = {
"engagement_id": {"type": "string"}, "run_id": {"type": "string"},
"discovery_execution_id": {"type": ["string", "null"], "description": "Run input: the Discovery run's execution id."},
"discovery_approval_ref": {"type": ["string", "null"], "description": "Run input: the Discovery approval (ADR 0002)."},
"artifact_ids": {"type": ["array", "string", "null"], "description": "Run input: the Discovery package's artifact id(s)."},
"rate_card_document": {"type": ["string", "null"], "description": "Run input: the rate card's JSON as text (ADR 0009); only its id and sha256 are used."},
"agent_versions": {"type": "object", "additionalProperties": {"type": "string"},
"description": "Each Assessment agent's version when the workflow was built, set as a static input by scripts/build_workflow.py."},
}
def schema(title: str, leave_out: set) -> dict:
props = dict(RUN)
for name, (part, field) in package.INPUTS.items():
if part in leave_out:
continue
src = json.loads((ROOT / PRODUCER[part] / "schemas" / "output.json").read_text())["properties"][field]
t = src.get("type") or "string"
props[name] = {"type": sorted(set([t] if isinstance(t, str) else t) | {"null"}),
"description": f"{PRODUCER[part]}: {field}. Copied unchanged; no enum, so no value the producer "
f"can hold is refused."}
if "report" in leave_out: # the report step also reads the Discovery package (ADR 0015 addendum)
props["discovery_documents"] = {"type": ["string", "null"], "description": "The parse step's text "
"(p1.parsed_content): the Discovery package, read in code to say what each "
"application is. The model never receives it."}
return {"$schema": "https://json-schema.org/draft/2020-12/schema", "title": title, "type": "object",
"required": ["engagement_id", "run_id"], "properties": props}
for folder, title, leave_out in (("cp1-assessment-package-agent", "Assessment package inputs", set()),
("cp1-assessment-report-agent", "Assessment report inputs", {"report"})):
(ROOT / folder / "schemas" / "input.json").write_text(json.dumps(schema(title, leave_out), indent=2, ensure_ascii=False) + "\n")
print(f"wrote {folder}/schemas/input.json")