From e06013e1fe0c1bca0236833db5ba1ad0af1673d1 Mon Sep 17 00:00:00 2001 From: XuJian <265865031+xujiantop-crypto@users.noreply.github.com> Date: Mon, 19 Oct 2026 21:50:34 +0800 Subject: [PATCH] docs: keep grouped service action counts in sync (#5991) * docs: keep grouped service action counts in sync * docs: guard service action source coverage * docs: require counts for generated action tables * docs: correct on-premises instance tag descriptions --- docs/services/autoscaling.md | 13 ++- docs/services/codedeploy.md | 13 ++- docs/services/index.md | 16 ++-- tools/docs/check_service_matrix.py | 58 ++++++++---- tools/docs/service_matrix.yaml | 19 ++++ tools/docs/test_check_service_matrix.py | 113 ++++++++++++++++++++++++ 6 files changed, 200 insertions(+), 32 deletions(-) diff --git a/docs/services/autoscaling.md b/docs/services/autoscaling.md index 90fd25f456..819e97dfd6 100644 --- a/docs/services/autoscaling.md +++ b/docs/services/autoscaling.md @@ -10,7 +10,7 @@ Floci implements the EC2 Auto Scaling API — stored-state management for launch - `arn:aws:autoscaling:::launchConfiguration::launchConfigurationName/` - `arn:aws:autoscaling:::scalingPolicy::autoScalingGroupName//policyName/` -## Supported Operations (47 total) +## Supported Operations (53 total) ### Launch Configurations @@ -29,6 +29,8 @@ Floci implements the EC2 Auto Scaling API — stored-state management for launch | `UpdateAutoScalingGroup` | Updates capacity bounds, cooldown, launch source, AZs | | `DeleteAutoScalingGroup` | `ForceDelete=true` terminates all instances before deletion | | `DescribeTags` | Group tags; filters `auto-scaling-group`, `key`, `value`, `propagate-at-launch` (values ORed, filters ANDed); `MaxRecords`/`NextToken` paging | +| `CreateOrUpdateTags` | Creates or updates group tags and their propagate-at-launch setting | +| `DeleteTags` | Removes named group tags | | `EnableMetricsCollection` | Records the named group metrics, or all 20 when none are named, as `EnabledMetrics` on `DescribeAutoScalingGroups`. `Granularity` is required and must be `1Minute`; an unknown metric name raises `ValidationError`. No metrics are published to CloudWatch | | `DisableMetricsCollection` | Removes the named metrics from `EnabledMetrics`, or all of them when none are named | @@ -67,6 +69,8 @@ EC2 instance can use a default subnet in a different zone. | Operation | Notes | |---|---| | `DescribeAutoScalingInstances` | Returns all ASG-tracked instances with lifecycle state and health status | +| `SetInstanceHealth` | Updates an instance's health status immediately; accepts but does not enforce the grace-period flag | +| `SetInstanceProtection` | Enables or disables scale-in protection for named instances in a group | | `SetDesiredCapacity` | Updates desired count; reconciler handles scale-out / scale-in within 10 s | | `AttachInstances` | Attaches existing EC2 instances to a group; sets lifecycle state to `InService` | | `DetachInstances` | Detaches instances from a group; optionally decrements desired capacity | @@ -74,6 +78,13 @@ EC2 instance can use a default subnet in a different zone. | `SuspendProcesses` | Records suspended scaling processes (empty list suspends all); reported back by `DescribeAutoScalingGroups` | | `ResumeProcesses` | Clears suspended processes (empty list resumes all) | +### Instance Refresh + +| Operation | Notes | +|---|---| +| `StartInstanceRefresh` | Starts replacement of group instances and returns a refresh ID | +| `DescribeInstanceRefreshes` | Returns refresh status and progress, with `MaxRecords`/`NextToken` paging | + ### Instance Refresh Recovery New instance refreshes retain the selected instances and their replacement progress diff --git a/docs/services/codedeploy.md b/docs/services/codedeploy.md index 2bc5225a33..69fb43f6be 100644 --- a/docs/services/codedeploy.md +++ b/docs/services/codedeploy.md @@ -11,7 +11,7 @@ Floci implements the CodeDeploy API — stored-state management for applications - `arn:aws:codedeploy:::deploymentconfig:` - `arn:aws:codedeploy:::deployment:` -## Supported Operations (30 total) +## Supported Operations (35 total) ### Applications @@ -66,12 +66,17 @@ Floci implements the CodeDeploy API — stored-state management for applications | `UntagResource` | Removes specific tag keys | | `ListTagsForResource` | Returns tags for a resource ARN | -### On-Premises (no-op) +### On-Premises Instances | Operation | Notes | |---|---| -| `AddTagsToOnPremisesInstances` | Accepted, no-op | -| `RemoveTagsFromOnPremisesInstances` | Accepted, no-op | +| `RegisterOnPremisesInstance` | Registers an instance name with an IAM session or user ARN | +| `DeregisterOnPremisesInstance` | Marks an instance as `Deregistered` while retaining its registration record | +| `GetOnPremisesInstance` | Returns registration information for one instance | +| `BatchGetOnPremisesInstances` | Returns registration information for named instances | +| `ListOnPremisesInstances` | Lists registered names, optionally filtered by status or tags | +| `AddTagsToOnPremisesInstances` | Adds or replaces tags by key on named instances | +| `RemoveTagsFromOnPremisesInstances` | Removes matching tag keys from named instances | ## Pre-seeded Built-in Deployment Configs diff --git a/docs/services/index.md b/docs/services/index.md index 6891f2e7b8..d4efb63ffd 100644 --- a/docs/services/index.md +++ b/docs/services/index.md @@ -27,7 +27,7 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac | [STS](sts.md) | `POST /` with `Action=` param | Query | 8 | | [AWS Sign-In](iam.md#aws-sign-in-login-credentials) | `/v1/authorize`, `/v1/token` | REST JSON | 2 | | [Organizations](organizations.md) | `POST /` + `X-Amz-Target: AWSOrganizationsV20161128.*` | JSON 1.1 | 56 | -| [Cognito](cognito.md) | `POST /` + `X-Amz-Target: AWSCognitoIdentityProviderService.*` | JSON 1.1 | 86 | +| [Cognito](cognito.md) | `POST /` + `X-Amz-Target: AWSCognitoIdentityProviderService.*` | JSON 1.1 | 90 | | [Cognito Identity](cognitoidentity.md) | `POST /` + `X-Amz-Target: AWSCognitoIdentityService.*` | JSON 1.1 | 12 | | [Global Accelerator](globalaccelerator.md) | `POST /` + `X-Amz-Target: GlobalAccelerator_V20180706.*` | JSON 1.1 | 22 | | [KMS](kms.md) | `POST /` + `X-Amz-Target: TrentService.*` | JSON 1.1 | 42 | @@ -70,7 +70,7 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac | [Amazon MQ](amazonmq.md) | `/v1/brokers/...` + RabbitMQ broker | REST JSON + AMQP | 5 | | [MWAA](mwaa.md) | `/` REST paths for environments + CLI/web proxy | REST JSON | 10 | | [Athena](athena.md) | `POST /` + `X-Amz-Target: AmazonAthena.*` | JSON 1.1 | 21 | -| [Glue](glue.md) | `POST /` + `X-Amz-Target: AWSGlue.*` | JSON 1.1 | 38 | +| [Glue](glue.md) | `POST /` + `X-Amz-Target: AWSGlue.*` | JSON 1.1 | 131 | | [Lake Formation](lakeformation.md) | `POST /` | REST JSON | 16 | | [Neptune](neptune.md) | `POST /` with `Action=` param + Gremlin TCP proxy | Query + WebSocket | 14 | | [DocumentDB](docdb.md) | `POST /` with `Action=` param + MongoDB container | Query + MongoDB wire | 13 | @@ -81,9 +81,9 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac | [EMR](emr.md) | `POST /` + `X-Amz-Target: ElasticMapReduce.*` | JSON 1.1 | 40 | | [EMR Serverless](emr-serverless.md) | `/applications/*`, `/tags/*` | REST JSON | 10 | | [Data Firehose](firehose.md) | `POST /` + `X-Amz-Target: Firehose_20150804.*` | JSON 1.1 | 12 | -| [ECS](ecs.md) | `POST /` + `X-Amz-Target: AmazonEC2ContainerServiceV20141113.*` | JSON 1.1 | 58 | +| [ECS](ecs.md) | `POST /` + `X-Amz-Target: AmazonEC2ContainerServiceV20141113.*` | JSON 1.1 | 59 | | [EFS](efs.md) | `/2015-02-01/...` | REST JSON | 26 | -| [EC2](ec2.md) | `POST /` with `Action=` param | EC2 Query | 78 | +| [EC2](ec2.md) | `POST /` with `Action=` param | EC2 Query | 198 | | [Lightsail](lightsail.md) | `POST /` + `X-Amz-Target: Lightsail_20161128.*` | JSON 1.1 | 79 local responses; 161 recognized actions | | [ACM](acm.md) | `POST /` + `X-Amz-Target: CertificateManager.*` | JSON 1.1 | 16 | | [ECR](ecr.md) | `POST /` + `X-Amz-Target: AmazonEC2ContainerRegistry_V20150921.*` (control plane) and `/v2/...` (data plane proxied to `registry:2`) | JSON 1.1 + OCI Distribution | 17 | @@ -100,15 +100,15 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac | [Bedrock AgentCore Control](bedrock-agentcore.md) | `/runtimes/*`, `/gateways/*`, `/memories/*`, `/identities/*`, `/browsers*`, `/browser-profiles*`, `/code-interpreters*`, `/resourcepolicy/*`, `/tags/{resourceArn}` | REST JSON | 65 (+ 3 tagging via shared `/tags/{arn}` route) | | [Bedrock AgentCore](bedrock-agentcore.md#data-plane-invokeagentruntime) | `/runtimes/{agentRuntimeArn}/invocations` | REST JSON (binary payload) | 1 (canned-response stub) | | [EKS](eks.md) | `/clusters`, `/clusters/{name}`, `/tags/{resourceArn}` | REST JSON | 7 | -| [ELB v2](elb.md) | `POST /` with `Action=` param | Query | 34 | +| [ELB v2](elb.md) | `POST /` with `Action=` param | Query | 37 | | [ELB Classic (v1)](elb-classic.md) | `POST /` with `Action=` and `Version=2012-06-01` | Query | 20 | | [WAF v2](wafv2.md) | `POST /` + `X-Amz-Target: AWSWAF_20190729.*` | JSON 1.1 | 35 | -| [Auto Scaling](autoscaling.md) | `POST /` with `Action=` param | Query | 33 | +| [Auto Scaling](autoscaling.md) | `POST /` with `Action=` param | Query | 53 | | [Application Auto Scaling](applicationautoscaling.md) | `POST /` + `X-Amz-Target: AnyScaleFrontendService.*` | JSON 1.1 | 10 | | [Elastic Beanstalk](elastic-beanstalk.md) | `POST /` with `Action=` or `Operation=` param | Query | 14 | | [CodeBuild](codebuild.md) | `POST /` + `X-Amz-Target: CodeBuild_20161006.*` | JSON 1.1 | 20 | | [AWS Batch](batch.md) | `/v1/...` | REST JSON | 10 | -| [CodeDeploy](codedeploy.md) | `POST /` + `X-Amz-Target: CodeDeploy_20141006.*` | JSON 1.1 | 30 | +| [CodeDeploy](codedeploy.md) | `POST /` + `X-Amz-Target: CodeDeploy_20141006.*` | JSON 1.1 | 35 | | [CodePipeline](codepipeline.md) | `POST /` + `X-Amz-Target: CodePipeline_20150709.*` | JSON 1.1 | 44 | | [AWS Network Firewall](network-firewall.md) | `POST /` + `X-Amz-Target: NetworkFirewall_20201112.*` | JSON 1.0 | 27 | | [AWS Service Catalog](service-catalog.md) | `POST /` + `X-Amz-Target: AWS242ServiceCatalogService.*` | JSON 1.1 | 89 | @@ -129,7 +129,7 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac | [Amazon SageMaker](sagemaker.md) | `POST /` + `X-Amz-Target: SageMaker.*` | JSON 1.1 | 20 | | [SageMaker Runtime](sagemaker.md#endpoint-hosting) | `/endpoints/{EndpointName}/invocations` | REST (binary payload) | 1 | | [Cloud Map](cloudmap.md) | `POST /` + `X-Amz-Target: Route53AutoNaming_v20170314.*` | JSON 1.1 | 22 | -| [AWS Config](config.md) | `POST /` + `X-Amz-Target: StarlingDoveService.*` | JSON 1.1 | 33 | +| [AWS Config](config.md) | `POST /` + `X-Amz-Target: StarlingDoveService.*` | JSON 1.1 | 36 | | [CloudTrail](cloudtrail.md) | `POST /` + `X-Amz-Target: com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101.*` | JSON 1.1 | 14 | | [Textract](textract.md) | `POST /` + `X-Amz-Target: Textract.*` | JSON 1.1 | 6 | | [Comprehend](comprehend.md) | `POST /` + `X-Amz-Target: Comprehend_20171127.*` | JSON 1.1 | 5 | diff --git a/tools/docs/check_service_matrix.py b/tools/docs/check_service_matrix.py index 93a8bb0385..a7e66ae005 100644 --- a/tools/docs/check_service_matrix.py +++ b/tools/docs/check_service_matrix.py @@ -45,6 +45,14 @@ CATALOG_SOURCE = "src/main/java/io/github/hectorvent/floci/core/common/ResolvedS MATRIX_DOC = "docs/services/index.md" REGISTRY = "tools/docs/service_matrix.yaml" +# These grouped rows already have one dispatcher each; removing a registry entry +# must not silently turn off their count check. +REQUIRED_ACTION_COUNT_SOURCES = frozenset({ + "autoscaling", "cloudmap", "codebuild", "codedeploy", "cognito", "config", + "ec2", "ecs", "elastic-beanstalk", "elb", "elb-classic", "glue", "iam", + "resource-groups-tagging", +}) + MATRIX_HEADING = "## Service Matrix" MATRIX_END_HEADING = "## Common Setup" @@ -183,14 +191,13 @@ def count_generated_actions(md_source: str) -> int | None: return count -def extract_action_counts(repo_root: Path) -> dict[str, int]: +def extract_action_counts(repo_root: Path, required_sources: frozenset[str] = frozenset()) -> dict[str, int]: """Extract mechanically verifiable action counts. Generated service documents are counted from their generated action-table - markers. IAM is a deferred non-tabular document, so its Query switch is - parsed directly using the same action parser as regen_action_docs.py. - Other services without generated action-table markers are intentionally - skipped here because their handlers use non-tabular or mixed dispatch - patterns that cannot be counted safely by the generic registry parser. + markers. Explicitly mapped non-tabular Query/JSON dispatchers are counted + from source with the same action parser as regen_action_docs.py. Mixed and + anchored rows remain outside this check until their operations can be + attributed to a single matrix row. """ md_source = (repo_root / MATRIX_DOC).read_text(encoding="utf-8") matrix_counts = extract_matrix_action_counts(md_source) @@ -198,7 +205,7 @@ def extract_action_counts(repo_root: Path) -> dict[str, int]: counts: dict[str, int] = {} # Generated service documents. - for slug in matrix_counts: + for slug in sorted(extract_matrix_slugs(md_source)): doc_path = repo_root / SERVICES_DIR / f"{slug}.md" if not doc_path.exists(): @@ -208,19 +215,32 @@ def extract_action_counts(repo_root: Path) -> dict[str, int]: generated_count = count_generated_actions(doc_source) if generated_count is not None: + if slug not in matrix_counts: + raise ValueError( + f"{MATRIX_DOC}: '{slug}' needs a numeric matrix row for its generated action table" + ) counts[slug] = generated_count - # IAM is intentionally non-tabular, so validate it from its handler. - iam_source = ( - repo_root - / "src/main/java/io/github/hectorvent/floci/services/iam/IamQueryHandler.java" - ) - - counts["iam"] = len( - regen_action_docs.extract_switch_actions( - iam_source.read_text(encoding="utf-8") + registry = yaml.safe_load((repo_root / REGISTRY).read_text(encoding="utf-8")) or {} + sources = registry.get("action_count_sources") + if not isinstance(sources, dict) or not sources: + raise ValueError(f"{REGISTRY}: action_count_sources must be a non-empty mapping") + missing = required_sources - sources.keys() + if missing: + raise ValueError(f"{REGISTRY}: required action count source(s) missing: {', '.join(sorted(missing))}") + for slug, relative_path in sources.items(): + if slug not in matrix_counts: + raise ValueError(f"{REGISTRY}: action count source '{slug}' has no numeric matrix row") + if slug in counts: + raise ValueError(f"{REGISTRY}: '{slug}' already has a generated action table") + if not isinstance(relative_path, str): + raise ValueError(f"{REGISTRY}: action count source '{slug}' needs a source path") + actions = regen_action_docs.extract_switch_actions( + (repo_root / relative_path).read_text(encoding="utf-8") ) - ) + if not actions: + raise ValueError(f"{REGISTRY}: action count source '{slug}' has no actions") + counts[slug] = len(set(actions)) return counts @@ -343,8 +363,8 @@ def main(argv: list[str] | None = None) -> int: try: matrix_action_counts = extract_matrix_action_counts(md_source) - source_action_counts = extract_action_counts(repo_root) - except (ValueError, OSError) as exc: + source_action_counts = extract_action_counts(repo_root, REQUIRED_ACTION_COUNT_SOURCES) + except (ValueError, OSError, yaml.YAMLError) as exc: print(f"error: {exc}", file=sys.stderr) return 1 diff --git a/tools/docs/service_matrix.yaml b/tools/docs/service_matrix.yaml index 4550e86884..da4af43300 100644 --- a/tools/docs/service_matrix.yaml +++ b/tools/docs/service_matrix.yaml @@ -64,6 +64,25 @@ aliases: # row lands - don't wait for it to expire. deferred: [] +# Non-tabular pages with one Query/JSON action dispatcher per numeric base row. +# These counts are checked against the handler switch, without flattening the +# grouped documentation. Anchored and mixed-dispatch rows need separate rules. +action_count_sources: + autoscaling: src/main/java/io/github/hectorvent/floci/services/autoscaling/AutoScalingQueryHandler.java + cloudmap: src/main/java/io/github/hectorvent/floci/services/cloudmap/CloudMapHandler.java + codebuild: src/main/java/io/github/hectorvent/floci/services/codebuild/CodeBuildJsonHandler.java + codedeploy: src/main/java/io/github/hectorvent/floci/services/codedeploy/CodeDeployJsonHandler.java + cognito: src/main/java/io/github/hectorvent/floci/services/cognito/CognitoJsonHandler.java + config: src/main/java/io/github/hectorvent/floci/services/configservice/ConfigServiceJsonHandler.java + ec2: src/main/java/io/github/hectorvent/floci/services/ec2/Ec2QueryHandler.java + ecs: src/main/java/io/github/hectorvent/floci/services/ecs/EcsJsonHandler.java + elastic-beanstalk: src/main/java/io/github/hectorvent/floci/services/elasticbeanstalk/ElasticBeanstalkQueryHandler.java + elb: src/main/java/io/github/hectorvent/floci/services/elbv2/ElbV2QueryHandler.java + elb-classic: src/main/java/io/github/hectorvent/floci/services/elb/ElbClassicQueryHandler.java + glue: src/main/java/io/github/hectorvent/floci/services/glue/GlueJsonHandler.java + iam: src/main/java/io/github/hectorvent/floci/services/iam/IamQueryHandler.java + resource-groups-tagging: src/main/java/io/github/hectorvent/floci/services/resourcegroupstagging/ResourceGroupsTaggingJsonHandler.java + # docs/services pages that intentionally have no Service Matrix row of their own. facet_pages: - cloudwatch-metric-filters-verification diff --git a/tools/docs/test_check_service_matrix.py b/tools/docs/test_check_service_matrix.py index 6f460308cf..d618217353 100644 --- a/tools/docs/test_check_service_matrix.py +++ b/tools/docs/test_check_service_matrix.py @@ -131,6 +131,119 @@ Another link to [SQS](sqs.md). } +@pytest.mark.parametrize("slug,handler", [ + ("ec2", "ec2/Ec2QueryHandler.java"), + ("ecs", "ecs/EcsJsonHandler.java"), + ("elb", "elbv2/ElbV2QueryHandler.java"), + ("glue", "glue/GlueJsonHandler.java"), +]) +def test_non_tabular_action_counts_follow_dispatcher(slug, handler): + root = c._repo_root() + source = root / "src/main/java/io/github/hectorvent/floci/services" / handler + expected = len(set(c.regen_action_docs.extract_switch_actions( + source.read_text(encoding="utf-8") + ))) + + assert c.extract_action_counts(root)[slug] == expected + + +def test_non_tabular_action_count_tracks_new_dispatch_cases(tmp_path): + matrix = tmp_path / "docs/services/index.md" + matrix.parent.mkdir(parents=True) + matrix.write_text( + "## Service Matrix\n\n| [Glue](glue.md) | Query | JSON | 2 |\n\n## Common Setup\n", + encoding="utf-8", + ) + registry = tmp_path / "tools/docs/service_matrix.yaml" + registry.parent.mkdir(parents=True) + registry.write_text("action_count_sources:\n glue: src/GlueJsonHandler.java\n", encoding="utf-8") + handler = tmp_path / "src/GlueJsonHandler.java" + handler.parent.mkdir(parents=True) + handler.write_text( + 'case "CreateTable" -> create();\ncase "GetTable" -> get();\n', + encoding="utf-8", + ) + + assert c.extract_action_counts(tmp_path)["glue"] == 2 + + handler.write_text( + handler.read_text(encoding="utf-8") + 'case "DeleteTable" -> delete();\n', + encoding="utf-8", + ) + assert c.extract_action_counts(tmp_path)["glue"] == 3 + + +def test_generated_action_table_requires_numeric_matrix_count(tmp_path): + matrix = tmp_path / "docs/services/index.md" + matrix.parent.mkdir(parents=True) + matrix.write_text( + "## Service Matrix\n\n| [EFS](efs.md) | REST | REST | TBD |\n" + "| [Glue](glue.md) | Query | JSON | 2 |\n\n## Common Setup\n", + encoding="utf-8", + ) + (matrix.parent / "efs.md").write_text( + "\n| Action | Description |\n" + "| --- | --- |\n| CreateFileSystem | Creates a file system |\n" + "\n", + encoding="utf-8", + ) + registry = tmp_path / "tools/docs/service_matrix.yaml" + registry.parent.mkdir(parents=True) + registry.write_text("action_count_sources:\n glue: src/GlueJsonHandler.java\n", encoding="utf-8") + handler = tmp_path / "src/GlueJsonHandler.java" + handler.parent.mkdir(parents=True) + handler.write_text('case "CreateTable" -> create();\ncase "GetTable" -> get();\n', encoding="utf-8") + + with pytest.raises(ValueError, match="efs.*numeric matrix row"): + c.extract_action_counts(tmp_path) + + +@pytest.mark.parametrize("source_entry", ["[]", "{}", "null"]) +def test_non_tabular_action_sources_cannot_be_disabled(tmp_path, source_entry): + matrix = tmp_path / "docs/services/index.md" + matrix.parent.mkdir(parents=True) + matrix.write_text( + "## Service Matrix\n\n| [Glue](glue.md) | Query | JSON | 2 |\n\n## Common Setup\n", + encoding="utf-8", + ) + registry = tmp_path / "tools/docs/service_matrix.yaml" + registry.parent.mkdir(parents=True) + registry.write_text(f"action_count_sources: {source_entry}\n", encoding="utf-8") + + with pytest.raises(ValueError, match="non-empty mapping"): + c.extract_action_counts(tmp_path) + + +def test_non_tabular_action_source_cannot_be_removed_silently(tmp_path): + matrix = tmp_path / "docs/services/index.md" + matrix.parent.mkdir(parents=True) + matrix.write_text( + "## Service Matrix\n\n| [Glue](glue.md) | Query | JSON | 2 |\n" + "| [EC2](ec2.md) | Query | Query | 1 |\n\n## Common Setup\n", + encoding="utf-8", + ) + registry = tmp_path / "tools/docs/service_matrix.yaml" + registry.parent.mkdir(parents=True) + registry.write_text( + "action_count_sources:\n glue: src/GlueJsonHandler.java\n" + " ec2: src/Ec2QueryHandler.java\n", encoding="utf-8", + ) + source_dir = tmp_path / "src" + source_dir.mkdir() + (source_dir / "GlueJsonHandler.java").write_text( + 'case "CreateTable" -> create();\ncase "GetTable" -> get();\n', encoding="utf-8", + ) + (source_dir / "Ec2QueryHandler.java").write_text( + 'case "DescribeInstances" -> describe();\n', encoding="utf-8", + ) + + required = frozenset({"glue", "ec2"}) + assert c.extract_action_counts(tmp_path, required) == {"glue": 2, "ec2": 1} + registry.write_text("action_count_sources:\n glue: src/GlueJsonHandler.java\n", encoding="utf-8") + with pytest.raises(ValueError, match="required action count source\\(s\\) missing: ec2"): + c.extract_action_counts(tmp_path, required) + + def test_extract_matrix_slugs_raises_on_missing_heading(): # A renamed/reordered heading must fail loudly rather than silently returning an # empty slug set, which would make every registered service look undocumented.