# 0017. A live run's scope is every resource under the scope root, planned and checked in code | | | |---|---| | Status | Accepted | | Date | 2026-11-04 | | Decided by | Product owner, 2026-11-04: "that scope needs to be extend to all resources" | | Requirements changed | ALZ-DSC-01 (ADO 3214451): what a live run's scope entries are, and how the plan is made. ALZ-DSC-08 (ADO 3214458): what live coverage is measured against | ## Context Azure run `exec_29ec31ba92ab` (2026-11-04) was scoped to the resource group `crucible-kab-dev`. That group holds 11 resources, but the run scanned, inventoried and reported 3: the AKS cluster, a storage account and a PostgreSQL server. - The planner built a live scope only from `list_servers`, `list_workloads`, `list_kubernetes_clusters` and `list_data_stores`. Two Key Vaults, two managed identities, a DNS zone, an Event Grid topic, a private endpoint and a network interface were never scope entries. They weren't declared as gaps either. - The critic measured coverage with the same four tools, so it reported "coverage complete" and passed the run. ## Decision - **Every resource under the connection's scope root is accounted for.** The planner's code lists the scope with `_list_resources`, every page at 200 a page, and puts each resource in exactly one place (`app/scope.py`): - **a scope entry:** any resource that isn't structure or a child component; - **folded into its parent, with the rule recorded:** - Azure: disks, network interfaces, VM extensions, scale-set instances; - GCP: disks, GKE node pools; - **structure:** subscriptions, resource groups, management groups, projects, folders and organisations, which are counted but aren't assets. - **A live plan is built in code, with no model call** (`app/plan.py`, `pre_process`): - one `scan_target` per scope entry, in batches of 10; - a `classify_data` per data store; - one `collect_network` and one `trace_dependencies`; - `source_gaps` set by the same rules as before. The run context still only narrows (`context.scope.regions`, `context.scope.exclude`), as declared gaps. The new `scope_accounting` output gives `listed`, `scope_entries`, `folded` (each with its rule) and `structure`. The sample estate keeps its model and prompt unchanged. - **An incomplete listing fails the planner step.** A refused or failed page, or more than 100 pages, means no plan is made, rather than a plan of part of the estate. - **The critic counts coverage itself.** Its code lists the scope again with the same rules: `app/scope.py` is identical in both agents, and a test compares the two files. It compares that listing with the findings and the planner's declared gaps, and gives the model `live_scope`: counts, the uncovered ids (up to 200, with the exact count) and any listing issues. The model copies it into `coverage_gaps` and `coverage_complete`. A listing issue fails coverage. ## Consequences - Supporting services are discovered, inventoried and reported: Key Vault, identities, DNS, messaging, private endpoints, registries, monitoring and so on. The Well-Architected review and Assessment (ALZ-ASM-05) see the same estate. - The critic can't pass a run that skipped a resource type. - **Scale:** - At subscription scope, about 650 resources become about 600 scan tasks. The planner handles that in code. - The scan executor (ALZ-DSC-02) still has a model call each resource's metadata in one request. That fits a resource group, but not a large subscription. - Batching the scan in code, as ADR 0015 did for the inventory, is the next change before a subscription-wide run. - Folding is a fixed list. A new child-component type shows up as a scope entry until it's added, which over-counts but never drops anything.