Platform scripts, MCP servers, deployment and docs for the KAB runs

- Scripts to run workflows from a YAML context or run inputs (kab_run_workflow.py, with
  --input name=@file), store per-project discovery connections, bootstrap agent MCP keys,
  refresh the KAB token, publish reports and build estate snapshots.
- Hyperscaler discovery servers extended in place; cloud-knowledge folded into them.
- deploy/crucible-kab-dev.yaml: the Discovery package agent and the Assessment agents.
- Platform issue write-ups and current-wiring notes under docs/platform-issues/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-05 22:13:25 +00:00
parent c14a94f33b
commit f659564208
71 changed files with 2818 additions and 2821 deletions

View File

@@ -0,0 +1,189 @@
# MCP tools and context: individual-agents pattern
| | |
|---|---|
| Date | 2026-11-01 |
| Environment | KAB dev (`crucible-kab-dev-aks`), agent runtime 0.35.7 |
| Component | ALZ-F01 Discovery, `individual-agents/`; the KAB workflow executor |
| Severity | High. The pattern depends on this, and the outputs below reach no later step |
| Status | Open. The platform team hasn't confirmed how large step outputs are handled (ADR 0010) |
| Found by | Review of the agents' tools and the workflow's wiring |
For engineers changing these agents, and for reviewers judging their output. Agents collect their own facts, and the workflow carries only what each step returns.
The main tables are generated from `agent.yaml`, `schemas/` and the workflow export. `scripts/check_context_doc.py`, in the Feature folder, fails if they drift. Run it after changing an agent's tools, a schema or `STEPS`.
## Summary
- **Each agent reads its own sources.** It holds only the read-only MCP tools its job needs.
- **Each agent starts blank.** It has no memory of earlier steps or runs, and it sees no other agent's reasoning.
- **Context is data, not conversation.** A step gets `engagement_id`, `run_id`, and the named fields it's wired to receive.
- **There's no shared store.** A step's output exists only as its reply (ADR 0010).
## Why each agent has MCP tools
| Reason | What it means |
|---|---|
| Least privilege | An agent can only use the tools it declares. The classifier can't scan the estate, and the planner can't query the CMDB. |
| Evidence from the source | Agents cite real tool results, so a finding can be checked. Each fact carries an evidence reference. |
| An independent check | The critic reads the scope and the call log itself, and doesn't rely on what other agents report. |
| Read-only | Every tool only reads. The stories' write tools are replaced by each agent's reply (ADR 0003). |
Only top-level agents can hold MCP tools. That's one reason this pattern differs from the sub-agent pattern, where the orchestrator makes every call.
| Step | Agent | MCP server: tools | What it fetches |
|---|---|---|---|
| s1 | `cp1-discovery-planner-agent` | `alz-scope`: `get_scope`, `list_sources`, `get_budgets` | What is in scope, and the limits |
| s2 | `cp1-estate-scan-executor-agent` | `alz-estate`: `scan_target`; `alz-cloud`: `get_resource_metadata` | Facts about each estate target |
| s3 | `cp1-asset-inventory-normalisation-agent` | `alz-inventory`: `list_apps`, `get_app` | Application records |
| s4 | `cp1-cmdb-itsm-reconciliation-agent` | `alz-cmdb`: `ingest_cmdb`, `ingest_itsm`, `cmdb_query`, `diff_records` | CMDB and ITSM records to compare |
| s5 | `cp1-data-classification-agent` | `alz-schema`: `scan_schema` | Database schema metadata |
| s6 | `cp1-network-discovery-assessment-agent` | `alz-network`: `collect_topology`, `map_flows`, `analyze_bottlenecks` | Network layout and traffic |
| s7 | `cp1-dependency-mapping-agent` | `alz-dependency`: `get_dependencies`, `trace_calls`, `trace` | Evidence of how systems connect |
| s8 | `cp1-discovery-critic-agent` | `alz-scope`: `get_scope`; `alz-evidence`: `get_call_log`, `get_guard_hits` | The true scope, and what the agents actually called |
| s9 | `cp1-discovery-report-agent` | None | It calls no model or MCP tool. It writes `report_markdown`, `report_html` and `final_html` from code, and returns `counts` |
The server names are logical. In the sample setup, all nine are registered in the `CP1 Agentic Landing Zone` tenant against one server, `alz-discovery-sample`, so each can later point to a real system. The hyperscaler discovery servers aren't declared here, so a run reads only the Meridian sample.
## How context carries across
```
Run form: engagement_id, run_id ──────────► every step
Upload (u1) ── parsed_content ────────────► s1, s3
s1 Planner ── tasks ──┬─► s2 Scan ── findings ─► s3 Inventory ── records ─┐
├─► s4 CMDB ◄───────────────────────────────────────┤
└─► s6 Network ◄────────────────────────────────────┤
s5 Classification ◄──────┤
s7 Dependencies ◄────────┘
(also drift_items from s4,
flows from s6)
s8 Critic ◄── seven fields from earlier steps
s9 Report ◄── 21 fields from s1 to s8 ──► Engagement Lead's approval
```
1. **The reply is checked.** It must match the step's output contract. If it doesn't, it's sent back once, then the step fails with `output_contract_violation`.
2. **The workflow copies named fields.** `from_steps` wires, for example, `s2.findings` into s3's `findings`.
3. **The input is checked.** A request that breaks the input contract is refused before any model call.
4. **The build checks the wiring.** `scripts/build_workflow.py` asserts that every field passed between steps exists on both sides.
| Step | Agent | Receives | Returns |
|---|---|---|---|
| s1 | `discovery-planner` | `source_documents` from `u1.parsed_content` | `plan_id`, `engagement_id`, `tasks`, `coverage_gaps`, `summary`, `findings_note` |
| s2 | `estate-scan-executor` | `tasks` from `s1.tasks` | `findings` |
| s3 | `asset-inventory-normalisation` | `findings` from `s2.findings`, `source_documents` from `u1.parsed_content` | `records`, `sme_review_queue` |
| s4 | `cmdb-itsm-reconciliation` | `tasks` from `s1.tasks`, `records` from `s3.records`, `source_gaps` from `s1.source_gaps` | `report_id`, `engagement_id`, `drift_items`, `itsm_signals`, `summary` |
| s5 | `data-classification` | `records` from `s3.records`, `source_gaps` from `s1.source_gaps` | `stores` |
| s6 | `network-discovery-assessment` | `tasks` from `s1.tasks`, `records` from `s3.records` | `ranges`, `flows`, `findings` |
| s7 | `dependency-mapping` | `records` from `s3.records`, `drift_items` from `s4.drift_items`, `flows` from `s6.flows` | `graph_id`, `engagement_id`, `edges`, `nodes`, `orphans`, `validation_queue` |
| s8 | `discovery-critic` | `coverage_gaps` from `s1.coverage_gaps`, `findings` from `s2.findings`, `records` from `s3.records`, `drift_items` from `s4.drift_items`, `stores` from `s5.stores`, `network_findings` from `s6.findings`, `edges` from `s7.edges`, `source_gaps` from `s1.source_gaps` | `coverage_complete`, `coverage_gaps`, `declared_gaps`, `injections_found`, `obeyed_injection`, `unsupported_claims`, `consistency_issues`, `parse_failures`, `tool_call_issues`, `verdict`, `note` |
| s9 | `discovery-report` | `plan_summary` from `s1.summary`, `source_gaps` from `s1.source_gaps`, `coverage_gaps` from `s1.coverage_gaps`, `scan_findings` from `s2.findings`, `records` from `s3.records`, `sme_review_queue` from `s3.sme_review_queue`, `drift_items` from `s4.drift_items`, `itsm_signals` from `s4.itsm_signals`, `stores` from `s5.stores`, `network_findings` from `s6.findings`, `ranges` from `s6.ranges`, `edges` from `s7.edges`, `nodes` from `s7.nodes`, `orphans` from `s7.orphans`, `validation_queue` from `s7.validation_queue`, `verdict` from `s8.verdict`, `critic_note` from `s8.note`, `obeyed_injection` from `s8.obeyed_injection`, `unsupported_claims` from `s8.unsupported_claims`, `consistency_issues` from `s8.consistency_issues`, `parse_failures` from `s8.parse_failures`, `tool_call_issues` from `s8.tool_call_issues` |
`source_gaps` from the planner reaches s4, s5, s8 and s9, so a missing CMDB, ITSM, flow or schema source is declared and never read as a clean result.
## What doesn't carry across
These output fields reach no later step, not even the critic. They're kept in the step's reply, which KAB registers as an `execution_output` artifact, but no agent reads or judges them.
| Step | Fields |
|---|---|
| s1 | `plan_id`, `engagement_id`, `findings_note` |
| s2 | |
| s3 | |
| s4 | `report_id`, `engagement_id`, `summary` |
| s5 | |
| s6 | |
| s7 | `graph_id`, `engagement_id` |
| s8 | `coverage_complete`, `coverage_gaps`, `declared_gaps`, `injections_found`, `not_checked` |
Most are identifiers. Since the report step was added (ADR 0012), the findings once listed here reach the reader, so the agents still don't see them, but the Engagement Lead does.
## Risks to watch
| Risk | Effect | What to check |
|---|---|---|
| Unjudged outputs | The critic can't see the fields above | Whether a problem appears only there |
| Growing context | `records` reaches four agents, and the critic receives seven fields | Truncation, slow steps, or missed entries on large estates |
| Large hand-offs | ADR 0010 relies on the executor handling large outputs, which the platform team hasn't confirmed | Whether a later step received its field in full |
| No memory between runs | A rerun starts from nothing | Repeated work and inconsistent ids across runs |
| No hash chain | Nothing proves a hand-off wasn't altered. Integrity rests on evidence references and the critic's call-log check | Evidence references that don't match a real call |
| Silent gaps | An agent only knows its inputs and tools | Scope entries that disappear between steps |
| Shared model | The critic and the executors all use `gpt-5.6-sol` (ADR 0008) | That the critic's `note` says so, and whether its verdict is earned |
## For the platform team
- Does the executor externalise large step outputs between steps, and from what size? (ADR 0010)
- Can a later step read an earlier step's fields that aren't wired to it, without adding them to every contract?
## Current wiring (2026-11-05)
The sections above describe the pattern as it stood on 2026-11-01, on the Meridian sample estate. Since then:
- **Live providers (ADR 0013).** Each agent also declares read-only tools on the live discovery servers, under the
gateway's display names (`Azure Discovery`, `Google Cloud Discovery`). The `alz-*` sample tools still serve
`provider: sample`.
- **Code answers several steps.** The planner, CMDB step, dependency map, critic's coverage counts,
Well-Architected review, report and package are computed in `pre_process` hooks (ADRs 0014, 0015, 0017, 0018,
0019, 0020). Where a model is used, its reply is checked in code.
- **New steps:** the Well-Architected review (`s11`, ADR 0014), and the Discovery package for the Assessment workflow
(`s13`, ADR 0020), which runs after the report's review point and carries every step's output to F02 in one
artifact. Fields marked unread below now reach F02 through the package, except the run's own ids.
- **Applications and owners (ADR 0021):** the dependency step groups records into applications (CMDB business
service, then application tag, then container, then a judged model proposal) and names each asset's owner from the
CMDB or an owner tag; the report and the package carry them.
This section is written from `workflows/cp1-alz-discovery-individual.json` and each `agent.yaml`, and
`scripts/check_context_doc.py` checks it.
### Tools by step
| Step | Agent | Answered by | MCP tools |
|---|---|---|---|
| s1 | `cp1-discovery-planner-agent` | code (`hooks`) | alz-scope: `get_scope`, `list_sources`, `get_budgets`; Azure Discovery: `azure_list_accounts`, `azure_list_resources`, `azure_list_servers`, `azure_list_workloads`, `azure_list_kubernetes_clusters`, `azure_list_data_stores`; Google Cloud Discovery: `gcp_list_accounts`, `gcp_list_resources`, `gcp_list_servers`, `gcp_list_workloads`, `gcp_list_kubernetes_clusters`, `gcp_list_data_stores` |
| s2 | `cp1-estate-scan-executor-agent` | model | alz-estate: `scan_target`; alz-cloud: `get_resource_metadata`; Azure Discovery: `azure_get_resource_metadata`; Google Cloud Discovery: `gcp_get_resource_metadata` |
| s3 | `cp1-asset-inventory-normalisation-agent` | code (`hooks`), with a judged sub-agent | alz-inventory: `list_apps`, `get_app` |
| s4 | `cp1-cmdb-itsm-reconciliation-agent` | code (`hooks`), with a judged sub-agent | alz-cmdb: `ingest_cmdb`, `ingest_itsm`, `cmdb_query`, `diff_records`; Azure Discovery: `azure_list_resources`; Google Cloud Discovery: `gcp_list_resources` |
| s5 | `cp1-data-classification-agent` | model | alz-schema: `scan_schema`; Azure Discovery: `azure_list_data_stores`; Google Cloud Discovery: `gcp_list_data_stores` |
| s6 | `cp1-network-discovery-assessment-agent` | model | alz-network: `collect_topology`, `map_flows`, `analyze_bottlenecks`; Azure Discovery: `azure_get_network_topology`; Google Cloud Discovery: `gcp_get_network_topology` |
| s7 | `cp1-dependency-mapping-agent` | code (`hooks`), with a judged sub-agent | alz-dependency: `get_dependencies`, `trace_calls`, `trace` |
| s8 | `cp1-discovery-critic-agent` | code (`hooks`) | alz-scope: `get_scope`; alz-evidence: `get_call_log`, `get_guard_hits`; Azure Discovery: `azure_list_resources`, `azure_list_servers`, `azure_list_workloads`, `azure_list_kubernetes_clusters`, `azure_list_data_stores`; Google Cloud Discovery: `gcp_list_resources`, `gcp_list_servers`, `gcp_list_workloads`, `gcp_list_kubernetes_clusters`, `gcp_list_data_stores` |
| s11 | `cp1-well-architected-review-agent` | code (`hooks`) | Azure Discovery: `azure_list_servers`, `azure_list_workloads`, `azure_list_kubernetes_clusters`, `azure_list_data_stores`, `azure_get_network_topology`, `azure_list_organization_policies`, `azure_list_resource_policies`, `azure_list_recommendations`, `azure_search_well_architected`; Google Cloud Discovery: `gcp_list_servers`, `gcp_list_workloads`, `gcp_list_kubernetes_clusters`, `gcp_list_data_stores`, `gcp_get_network_topology`, `gcp_list_organization_policies`, `gcp_list_recommendations`, `gcp_search_well_architected` |
| s9 | `cp1-discovery-report-agent` | code (`hooks`) | None |
| s13 | `cp1-discovery-package-agent` | code (`hooks`) | None |
### Hand-offs
| Step | Takes | Returns |
|---|---|---|
| s1 | `source_documents` from `u1.parsed_content` | `plan_id`, `engagement_id`, `tasks`, `coverage_gaps`, `summary`, `findings_note`, `source_gaps`, `scope_accounting` |
| s2 | `tasks` from `s1.tasks` | `findings` |
| s3 | `findings` from `s2.findings`, `source_documents` from `u1.parsed_content` | `records`, `sme_review_queue` |
| s4 | `tasks` from `s1.tasks`, `records` from `s3.records`, `source_gaps` from `s1.source_gaps`, `source_documents` from `u1.parsed_content` | `report_id`, `engagement_id`, `drift_items`, `itsm_signals`, `summary`, `injections_found`, `cmdb_sources`, `note`, `cis`, `relationships`, `dangling_relationships` |
| s5 | `records` from `s3.records`, `source_gaps` from `s1.source_gaps` | `stores` |
| s6 | `tasks` from `s1.tasks`, `records` from `s3.records` | `ranges`, `flows`, `findings`, `topology_summary` |
| s7 | `records` from `s3.records`, `drift_items` from `s4.drift_items`, `flows` from `s6.flows`, `findings` from `s2.findings`, `cmdb_cis` from `s4.cis`, `cmdb_relationships` from `s4.relationships`, `cmdb_dangling` from `s4.dangling_relationships` | `graph_id`, `engagement_id`, `edges`, `nodes`, `orphans`, `validation_queue`, `folded_dependencies`, `dangling`, `graph_comparison`, `note`, `applications`, `asset_owners`, `ungrouped_assets`, `applications_note` |
| s8 | `coverage_gaps` from `s1.coverage_gaps`, `findings` from `s2.findings`, `records` from `s3.records`, `drift_items` from `s4.drift_items`, `stores` from `s5.stores`, `network_findings` from `s6.findings`, `edges` from `s7.edges`, `source_gaps` from `s1.source_gaps`, `cmdb_injections` from `s4.injections_found`, `nodes` from `s7.nodes`, `folded_dependencies` from `s7.folded_dependencies` | `coverage_complete`, `coverage_gaps`, `declared_gaps`, `injections_found`, `obeyed_injection`, `unsupported_claims`, `consistency_issues`, `parse_failures`, `tool_call_issues`, `verdict`, `note`, `not_checked` |
| s11 | `records` from `s3.records`, `source_gaps` from `s1.source_gaps`, `verdict` from `s8.verdict` | `engagement_id`, `run_id`, `provider`, `status`, `note`, `pillars`, `checks`, `recommendations`, `call_issues`, `evidence_refs`, `waf_markdown`, `waf_html`, `final_waf_html` |
| s9 | `topology_summary` from `s6.topology_summary`, `waf_status` from `s11.status`, `waf_pillars` from `s11.pillars`, `waf_note` from `s11.note`, `plan_summary` from `s1.summary`, `coverage_gaps` from `s1.coverage_gaps`, `source_gaps` from `s1.source_gaps`, `scan_findings` from `s2.findings`, `records` from `s3.records`, `sme_review_queue` from `s3.sme_review_queue`, `drift_items` from `s4.drift_items`, `itsm_signals` from `s4.itsm_signals`, `stores` from `s5.stores`, `network_findings` from `s6.findings`, `ranges` from `s6.ranges`, `edges` from `s7.edges`, `nodes` from `s7.nodes`, `orphans` from `s7.orphans`, `validation_queue` from `s7.validation_queue`, `verdict` from `s8.verdict`, `critic_note` from `s8.note`, `obeyed_injection` from `s8.obeyed_injection`, `unsupported_claims` from `s8.unsupported_claims`, `consistency_issues` from `s8.consistency_issues`, `parse_failures` from `s8.parse_failures`, `tool_call_issues` from `s8.tool_call_issues`, `cmdb_sources` from `s4.cmdb_sources`, `cmdb_injections` from `s4.injections_found`, `graph_comparison` from `s7.graph_comparison`, `folded_dependencies` from `s7.folded_dependencies`, `dangling` from `s7.dangling`, `applications` from `s7.applications`, `asset_owners` from `s7.asset_owners`, `ungrouped_assets` from `s7.ungrouped_assets`, `source_documents` from `u1.parsed_content` | `engagement_id`, `run_id`, `verdict`, `counts`, `report_markdown`, `report_html`, `final_html` |
| s13 | `plan_id` from `s1.plan_id`, `plan_summary` from `s1.summary`, `coverage_gaps` from `s1.coverage_gaps`, `source_gaps` from `s1.source_gaps`, `scope_accounting` from `s1.scope_accounting`, `scan_findings` from `s2.findings`, `records` from `s3.records`, `sme_review_queue` from `s3.sme_review_queue`, `drift_items` from `s4.drift_items`, `itsm_signals` from `s4.itsm_signals`, `cmdb_summary` from `s4.summary`, `cmdb_cis` from `s4.cis`, `cmdb_relationships` from `s4.relationships`, `cmdb_dangling` from `s4.dangling_relationships`, `cmdb_sources` from `s4.cmdb_sources`, `cmdb_injections` from `s4.injections_found`, `stores` from `s5.stores`, `ranges` from `s6.ranges`, `flows` from `s6.flows`, `network_findings` from `s6.findings`, `topology_summary` from `s6.topology_summary`, `nodes` from `s7.nodes`, `edges` from `s7.edges`, `orphans` from `s7.orphans`, `validation_queue` from `s7.validation_queue`, `folded_dependencies` from `s7.folded_dependencies`, `dangling` from `s7.dangling`, `graph_comparison` from `s7.graph_comparison`, `applications` from `s7.applications`, `asset_owners` from `s7.asset_owners`, `ungrouped_assets` from `s7.ungrouped_assets`, `applications_note` from `s7.applications_note`, `verdict` from `s8.verdict`, `critic_note` from `s8.note`, `coverage_complete` from `s8.coverage_complete`, `unsupported_claims` from `s8.unsupported_claims`, `consistency_issues` from `s8.consistency_issues`, `obeyed_injection` from `s8.obeyed_injection`, `not_checked` from `s8.not_checked`, `waf_status` from `s11.status`, `waf_pillars` from `s11.pillars`, `waf_checks` from `s11.checks`, `waf_recommendations` from `s11.recommendations`, `waf_note` from `s11.note`, `report_counts` from `s9.counts`, `report_markdown` from `s9.report_markdown` | `engagement_id`, `run_id`, `package_version`, `manifest`, `plan`, `scan`, `inventory`, `cmdb`, `classification`, `network`, `dependencies`, `critic`, `well_architected`, `report`, `applications` |
### Fields no later step reads
| Step | Fields |
|---|---|
| s1 | `engagement_id`, `findings_note` |
| s2 | |
| s3 | |
| s4 | `report_id`, `engagement_id`, `note` |
| s5 | |
| s6 | |
| s7 | `graph_id`, `engagement_id`, `note` |
| s8 | `coverage_gaps`, `declared_gaps`, `injections_found` |
| s11 | `engagement_id`, `run_id`, `provider`, `call_issues`, `evidence_refs`, `waf_markdown`, `waf_html` |
| s13 | `engagement_id`, `run_id`, `package_version`, `manifest`, `plan`, `scan`, `inventory`, `cmdb`, `classification`, `network`, `dependencies`, `critic`, `well_architected`, `report`, `applications` |
## Changing this
- **Adding a hand-off:** add it to `STEPS` in `scripts/build_workflow.py`, and to the receiving agent's `schemas/input.json`. Rebuild the workflow, and update this page.
- **Adding a tool:** add it to the agent's `mcp:` list and its prompt, and confirm it's read-only and registered at the gateway. A declared tool the gateway doesn't offer stops the agent at startup.
- **Changing a requirement:** add an ADR, as `CLAUDE.md` describes.

View File

@@ -9,6 +9,19 @@
| Status | Open; reported to the platform team for confirmation |
| Found by | Code review while building the CP1 Discovery workflows (`sub-agents/` and `individual-agents/`, ALZ-F01) |
## Update 2026-11-02
Further code reading, still @ `c89aedcb9`, answers two of the questions below:
- **Question 3, run-time ids: yes, already possible.** A run input named `<step_id>_artifact_ids` is mapped onto that
step's `artifact_ids` (`generic_workflow_executor.py:199-210`). An empty selection still fails.
- **Question 4, the `workflow_id` match: one run, chosen arbitrarily.** The query can match several runs' artifacts, but
`_resolve` returns the first document found (`artifacts_activities.py:139-146`). The match also has no tenant or
project filter: see [select-artifacts-tenant-scope](../select-artifacts-tenant-scope/report-2026-11-02.md).
Running or chaining one workflow from another is reported separately, in
[workflow-composition](../workflow-composition/report-2026-11-02.md).
## Summary
You can place an Artifacts step (`select_artifacts`) anywhere in a workflow, including between two agent steps. Within one run, though, it can't select anything an earlier step of that same run produced. The executor registers a run's step outputs as project artifacts only **after every step has finished**. While the run is in progress, its own outputs aren't artifacts yet.

View File

@@ -0,0 +1,61 @@
# Artifacts step: the lookup isn't scoped to the run's tenant or project
| | |
|---|---|
| Date | 2026-11-02 |
| Environment | `modernization-platform` @ `c89aedcb9`, read from source. Not reproduced on `crucible-kab-dev-aks` |
| Component | `agent-builder-temporal-workers`: the `select_artifacts` activity ("Artifacts" step). `agent-builder-api`: the execution routes' artifact check |
| Severity | Possibly high: a tenant-isolation defect, if it's confirmed. Unconfirmed, because another layer may block it |
| Status | Open; needs triage by the platform team |
| Found by | Code review of the hand-off from ALZ-F01 Discovery to ALZ-F02 Assessment |
## Summary
`SelectArtifactsActivity.execute` reads the raw `artifacts` collection with no tenant or project filter. It matches
each requested entry against the artifact's `_id`, `workflow_id` or `name`:
```python
# packages/agent-builder-temporal-workers/src/temporal/activities/artifacts_activities.py, around lines 107-125
collection = db.db["artifacts"]
...
query["$or"].extend([
{"_id": {"$in": raw_ids}},
{"workflow_id": {"$in": raw_ids}},
{"name": {"$in": raw_ids}},
])
```
From reading the code, an id, name or workflow id that belongs to another tenant or project would resolve, and its
content would be inlined into the run.
## What happens
| # | Behaviour | Code |
|---|---|---|
| 1 | The activity reads the unscoped `db.db["artifacts"]` collection | `temporal/activities/artifacts_activities.py:106` |
| 2 | Nothing in the activity refers to `tenant_id` or `project_id`, although `ActivityContext` carries both | `temporal/activities/base_activity.py:41-42` |
| 3 | The API's own check, when a run starts, uses the tenant-scoped `db._scoped("artifacts")`. But it only checks file types: it doesn't reject ids from outside the tenant | `agent-builder-api/src/api/workflows/workflow_execution_routes.py:1233` |
| 4 | That API check reads only ids set when the workflow was built (`step.inputs.artifact_ids`). Ids given as the run input `<step_id>_artifact_ids` aren't checked at all | Same file, `:1244`; the auto-mapping is in `generic_workflow_executor.py:199-210` |
| 5 | A match on `workflow_id` or `name` resolves to the first document found. Given a workflow id, the step returns one run's output, and nothing guarantees which | `artifacts_activities.py:139-146` `_resolve` |
## Not yet checked
- Whether Mongo users or roles in the worker limit what it can read.
- Whether the UI or the API validates run inputs before the run starts.
- Whether artifact names are unique across tenants. They're `{execution_id}_{step_id}` for step outputs, but a name on
an uploaded artifact is chosen by the uploader.
## Impact on the CP1 workflows
None found so far: CP1 runs in one tenant. Until this is triaged, CP1 workflows select artifacts by exact `_id` only.
## Questions for the platform team
1. Can a run in tenant A select an artifact owned by tenant B through this step?
2. If it can, could the query be scoped to the run's tenant and project, with any id resolving outside them rejected?
3. Should `workflow_id` and `name` matches be kept? If so, could they be made deterministic, for example the latest
completed run?
## Evidence
Code reading of `modernization-platform` @ `c89aedcb9`. Nothing was run against the platform, and nothing was changed.

View File

@@ -0,0 +1,81 @@
# A workflow can't run or chain another workflow
| | |
|---|---|
| Date | 2026-11-02 |
| Environment | `modernization-platform` @ `c89aedcb9`, read from source. Not reproduced on `crucible-kab-dev-aks` |
| Component | `agent-builder-temporal-workers`: the generic workflow executor and its step types. `agent-builder-api`: execution routes |
| Severity | Medium. Nothing fails, but a multi-stage engagement has to be wired by hand, workflow by workflow |
| Status | Open; for the platform team to confirm |
| Found by | Code review while planning the hand-off from ALZ-F01 Discovery to ALZ-F02 Assessment |
## Summary
A KAB workflow can't contain another workflow, and nothing starts a workflow when another one completes. Data moves
between workflows only through project artifacts. A person has to start the next workflow and name the artifact ids it
reads.
That affects any engagement that runs as a chain of workflows. CP1's Agentic Landing Zone runs as seven:
1. Discovery
2. Assessment
3. Strategy
4. Business Case
5. Target Architecture
6. Wave Planning
7. Landing Zone
Each one consumes the approved output of the one before.
How artifacts are registered, and how `select_artifacts` reads them, is covered in
[artifacts-step-within-a-run](../artifacts-step-within-a-run/report-2026-10-29.md). This report covers what's missing
around that: running or chaining workflows, and deriving inputs.
## What happens
| # | Behaviour | Code (`packages/agent-builder-temporal-workers/src/temporal/`) |
|---|---|---|
| 1 | The only step types are `sequential`, `parallel` and `conditional`, and every step must name an `agent`. No step type runs a workflow | `workflows/workflow_template_validator.py:14-16`, `:89-108` |
| 2 | No step activity starts a workflow. The fallback activity map holds agent calls, file parsing, `combine_inputs`, `format_for_ui` and domain activities | `activity_mapper.py:131-154` |
| 3 | Only two built-in pipelines start child workflows, and they're hard-coded. Designer-built and imported workflows can't do it | `workflows/language_ingestion_pipeline_workflow.py:122`, `workflows/business_rules_workflow.py:120` |
| 4 | When a run completes, nothing starts another one. The API only broadcasts `execution_complete` over Socket.IO | `agent-builder-api/src/services/execution_service.py:437` |
| 5 | Inputs can be derived only from inside the run. Sources are `from_steps` (dot paths), `from_workflow` (run inputs), run inputs named `<step_id>_<input>` (auto-mapped), `static` values, `combine_inputs`, and `==` / `!=` conditions over `steps.*` and `inputs.*`. There's no lookup or expression language, so nothing can resolve "the latest approved run of workflow A" | `workflows/generic_workflow_executor.py:194-210`, `:496-517`, `:600-660` |
No sub-workflow concept exists in `agent-builder-api/src` or `agent-builder-ui/src`. I searched for `sub_workflow`,
`subworkflow` and `nested`.
## Impact on the CP1 workflows
- **Assessment can't call Discovery or follow it automatically.** Each Feature runs on its own, and a person starts the
next one.
- **The artifact ids have to be entered by hand.** The Assessment run can take them as the run input
`<step_id>_artifact_ids` (behaviour 5), so the workflow needn't be edited for each engagement. But someone still has to
find the ids of the right Discovery run.
- **The platform doesn't check that the previous stage passed.** Outputs are registered whether or not the run failed,
the critic failed it, or a person rejected it. Each receiving workflow has to check for itself. Each selected entry
carries `metadata.status` and `source_execution_id` (`activities/artifacts_activities.py:468-482`), so the check can be
made.
## Workarounds in use
1. **Each Feature is its own workflow.** It starts with an Artifacts step, given the exact ids of the previous workflow's
artifacts as a run input. Never a name or a workflow id: see
[select-artifacts-tenant-scope](../select-artifacts-tenant-scope/report-2026-11-02.md).
2. **The receiving workflow checks the previous stage.** Its planner refuses to start unless the previous critic's verdict
is `pass` and its approval is recorded.
3. **References survive between runs.** Evidence references carry the producing `execution_id`.
4. **End-to-end tests run as one workflow.** Two stages can be combined into one workflow and wired with `from_steps`.
That gives up rerunning one stage on its own.
## Questions for the platform team
1. Is a workflow step planned that runs another workflow as a Temporal child workflow, waits for it, and exposes its
outputs to `from_steps`?
2. Or is a trigger planned: start workflow B when workflow A completes, passing A's registered artifact ids?
3. Could registered artifacts record the run's outcome (completed or failed, approved or rejected), and could
`select_artifacts` filter on it?
4. Could `select_artifacts` take an `execution_id` plus step ids, instead of raw artifact ids?
## Evidence
Code reading of `modernization-platform` @ `c89aedcb9`. Nothing was run against the platform, and nothing was changed.