cdk-preflight 1.31.0 → 1.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.jsii CHANGED
@@ -10111,6 +10111,6 @@
10111
10111
  "symbolId": "src/index:PreflightOptions"
10112
10112
  }
10113
10113
  },
10114
- "version": "1.31.0",
10115
- "fingerprint": "WVIrd6sYVLHRLcK9fR2aqOT/6GI2kOL+400zsG3UQw8="
10114
+ "version": "1.31.1",
10115
+ "fingerprint": "WvpiTdzKztLWdbVAnXyzHm8K6nBzmgMJBWxeit5R/TE="
10116
10116
  }
package/AGENTS.md CHANGED
@@ -85,10 +85,12 @@ The two failure modes are watched separately: **staleness** (the constraint disa
85
85
  - *Fix*: the constraint moved (a limit was raised, a value became allowed). Move the rule and both fixtures to the new boundary, measure it with `bench/verify-rule.sh`, and record the new evidence. If the constraint is gone altogether, delete the rule.
86
86
  - *Demote*: the cause is not known yet, or the measurement has to wait. Set `meta.severity: WARN` and every `make_diag_full` of the rule to `"WARN"`, and append to `repro.evidence` the line `BROKEN <run date> (#<issue>): fail template deployed clean; WARN until re-measured`. A demoted rule goes back to `ERROR` only with a new real-deploy evidence line that shows the fail template failing again.
87
87
 
88
- **An INCONCLUSIVE whose reason names a moved constraint is a BROKEN.** The monthly run marks a fail stack INCONCLUSIVE when it falls for a reason other than `repro.expect`. Read each reason: when the service's message states the constraint differently than the rule ("Priority is required when associating additional profiles" for a rule that allows one association per VPC, "only valid for COGNITO_USER_POOLS and JWT" for a rule that allows only Cognito), AWS changed the constraint and the rule is a false positive for every template in the new allowance. It gets the same seven days: narrow the rule to what the new message proves still fails, or demote it. A reason that only rewords the same constraint gets its `expect` updated in the same PR, so the next run measures it again (#463, #470).
88
+ **An INCONCLUSIVE whose reason names a moved constraint is a BROKEN.** The monthly run marks a fail stack INCONCLUSIVE when it falls for a reason other than `repro.expect`. Read each reason: when the service's message states the constraint differently than the rule ("Priority is required when associating additional profiles" for a rule that allows one association per VPC, "only valid for COGNITO_USER_POOLS and JWT" for a rule that allows only Cognito), AWS changed the constraint and the rule is a false positive for every template in the new allowance. It gets the same seven days: narrow the rule to what the new message proves still fails, or demote it. A reason that only rewords the same constraint gets its `expect` updated in the same PR, so the next run measures it again (#463, #470). The monthly issue lists these apart from the other INCONCLUSIVE rows, with the expected and the actual words side by side and the closest pairs first, since a moved number or a renamed enum value reads almost like the expected text.
89
89
 
90
90
  **A rule the monthly account cannot reach is skipped by name, not left INCONCLUSIVE.** When the fixtures need an account-level feature the monthly account lacks (Lambda tenancy, #429), `meta.yaml#monthlySkip: "<reason> (#<issue>)"` makes the monthly run report it SKIPPED with that reason; re-measure it by hand in the bench account. It is for the account, never for a fixture that simply fails: a skipped rule cannot turn BROKEN, so the issue stays open until the account can run it.
91
91
 
92
+ **A rule whose CloudFormation handler is broken is measured through the API.** When the resource handler itself stops answering (the RDS DBCluster handler returns only status 500 for `WithExpressConfiguration` since late 2026), the fail template keeps the resource under a never-true `Condition` for the rule to read and adds a probe custom resource that sends the same call to the service API and fails with its answer (`pf-rds-cluster-express-*`). The rule still has to fire on the template; the probe is what the monthly run measures.
93
+
92
94
  Re-running the one rule first (`monthly-verify` with `rules: <id>`) is allowed and often settles it — a BROKEN that fails again on the re-run was a flaky fixture, and the PR then records that run instead. What is not allowed is leaving it: an untouched BROKEN keeps failing users' synths until the next monthly run lists it again.
93
95
 
94
96
  **Adding.** Two gates, both mechanical, and nothing else can reject a candidate: the duplication guard (`test/rules.shard*.test.ts`) and the real-deploy gate (`bench/verify-rule.sh`). The real-deploy gate is the one thing that did *not* get looser with the widened scope, and deliberately so — `enforce` is the default mode, so a false positive is a hard synth failure in someone's CI. The CloudFront survey is the standing evidence: 3 of 9 documented constraints deployed clean (see "A doc sentence is a hypothesis" above). Volume comes from running the bench over more services, never from lowering that bar.
@@ -234,7 +236,7 @@ If you are a subagent running one of these phases, do not spawn further agents.
234
236
  **Variant sweep.** `scripts/variant-sweep.ts <schema-dir> <rule-id>` replaces each string in the fail template that the registry schema closes with an `enum` (a kind: `LaunchType`, `ProtocolType`, `PipelineType`) with its siblings, one at a time, and lists the ones on which the rule still fires: a claim that the constraint holds for that variant too, which the fail template never measured. A rule scoped wider than what it measured is one of the corpus's four false-positive shapes, and the corpus only finds it when a sibling happens to be in there. For a string the schema leaves open (`AWS::CodeBuild::Project.Artifacts.Type`, #456) it lists the property when the rule goes quiet on some value its rego names but keeps firing on a value it names nowhere (`to` is `*`): a `!=` that generalises past what was measured. The claims of 2026-12-05 are frozen in `rules/_variant-baseline.txt` (nearly all are kinds the constraint has nothing to do with, such as a VPC Lattice CIDR format under `TCP` vs `TCP_UDP`), which may only shrink. `npx projen variant-sweep` (a step of the `corpus` job) measures the rules changed since `main` and fails on any claim that is neither frozen nor declared, so a new rule starts with none. When the claim is wrong, narrow the rule to the kind it measured. When the constraint really holds for the sibling (you deployed it, or the documentation says it does not depend on the kind), declare it in `meta.yaml`: `variants: [{ path: ProtocolType, to: WEBSOCKET, why: "<run or doc>" }]` (`to: "*"` for an open string). The schema is `https://schema.cloudformation.us-east-1.amazonaws.com/CloudformationSchema.zip`; the whole pack takes about 50 CPU-minutes, so `--write-baseline` is for re-freezing only.
235
237
 
236
238
  **Reference sweep.** `npx projen reference-sweep` (`scripts/reference-sweep.ts`, a step of the `corpus` job) takes each rule's pass template and replaces the string leaves of the rule's resource types, one at a time, with a `Ref` and a `Fn::GetAtt` to a resource no rule reads (strings, numbers and booleans). The value of a reference is unknown until deploy, so a rule that fires on one of these mutants and not on the pass template is reading the reference as a literal. `rules/_lib/value.rego` has the readers: `_pf_lit(name, path)` is the value only when it is a literal (a string that is not a logical id, a number, a boolean), `_pf_is_lit(v)` tests a value already read, `_pf_unknown(name, path)` / `_pf_list_unknown(name, path)` hold when the template writes something there that cannot be read. A rule that fires on an absence or a mismatch (`not x in {...}`, `x != "Y"`, "the list does not contain Z") must add `not _pf_unknown(...)` for the value it compares; a size limit counts `_pf_json_size_min(doc)`. To read a key whose omission has no measured meaning, use `_pf_oval(o, k)` (undefined when absent, so the judgement drops) instead of an `object.get` default. `rules/_reference-baseline.txt` is a ratchet that may only shrink (empty since 2026-11-26: every firing found was fixed). A mutant that makes a rule error at run time fails regardless: one runtime error stops every rule of its service on that template (enforce mode then skips that service with a `pf-engine-error` warning rather than blocking synth, but its rules are lost).
237
- **Branch sweep.** `npx projen branch-sweep` (`scripts/branch-sweep.ts`, a step of the `corpus` job, about 4 minutes) takes every rule with two or more `violation` blocks and evaluates its fail template once per block, with only that block left in place. A block the fail template never fires is a claim no deploy has measured: the real-deploy gate and the monthly run deploy only the fail template, so if AWS relaxes that branch's constraint, nothing turns BROKEN and the rule goes on failing synth on templates that deploy. That is how `pf-rds-serverless-v2-capacity` kept Aurora PostgreSQL at 256 ACUs after the raise to 384 (#461): its only fail template was MySQL. `WARN` blocks are not counted: they never fail synth, so a relaxed constraint costs the user nothing there. The first run (2026-12-05) found 538 such blocks in 287 of the 387 multi-block rules (`pf-wafv2-label-syntax` measures one of its nine). They are frozen per rule in `rules/_branch-baseline.txt`, which may only shrink; a rule not listed there, which includes every new rule, must fire from every block on its fail template. To shrink it, give the block a fail template of its own, `templates/fail.<name>.template.json` (`<name>` lower-case letters, digits and hyphens, starting with a letter), with the observed rejection in `meta.yaml#repro.expect-<name>` (same one-line format as `expect`, verbatim in `evidence`), measure it with `CDKPF_FAIL_VARIANT=<name> bash bench/verify-rule.sh <rule-id>`, and lower the count. Adding a second violating resource to the one fail template does not measure the block: CloudFormation rolls back on the first failure and cancels the rest, so one deploy reports one branch. The duplication guard and the fires-on-fail test run on every branch template, the branch sweep counts a block as measured when any fail template reaches it, and the monthly run deploys each one as its own stack and reports it as `<rule-id>:fail.<name>`, so a branch whose constraint AWS relaxes shows up as BROKEN like the main template. A block that cannot be reached by a deployable template is demoted to `WARN` or removed. Cases in `test/rules.test.ts` do not count: they pin the rego, not AWS.
239
+ **Branch sweep.** `npx projen branch-sweep` (`scripts/branch-sweep.ts`, a step of the `corpus` job, about 4 minutes) takes every rule with two or more `violation` blocks and evaluates its fail template once per block, with only that block left in place. A block the fail template never fires is a claim no deploy has measured: the real-deploy gate and the monthly run deploy only the fail template, so if AWS relaxes that branch's constraint, nothing turns BROKEN and the rule goes on failing synth on templates that deploy. That is how `pf-rds-serverless-v2-capacity` kept Aurora PostgreSQL at 256 ACUs after the raise to 384 (#461): its only fail template was MySQL. `WARN` blocks are not counted: they never fail synth, so a relaxed constraint costs the user nothing there. The first run (2026-12-05) found 538 such blocks in 287 of the 387 multi-block rules (`pf-wafv2-label-syntax` measures one of its nine). They are frozen per rule in `rules/_branch-baseline.txt`, which may only shrink; a rule not listed there, which includes every new rule, must fire from every block on its fail template. To shrink it, give the block a fail template of its own, `templates/fail.<name>.template.json` (`<name>` lower-case letters, digits and hyphens, starting with a letter), with the observed rejection in `meta.yaml#repro.expect-<name>` (same one-line format as `expect`, verbatim in `evidence`), measure it with `CDKPF_FAIL_VARIANT=<name> bash bench/verify-rule.sh <rule-id>`, and lower the count. Adding a second violating resource to the one fail template does not measure the block: CloudFormation rolls back on the first failure and cancels the rest, so one deploy reports one branch. The duplication guard and the fires-on-fail test run on every branch template, the branch sweep counts a block as measured when any fail template reaches it, and the monthly run deploys each one as its own stack and reports it as `<rule-id>:fail.<name>`, so a branch whose constraint AWS relaxes shows up as BROKEN like the main template. A block that cannot be reached by a deployable template is demoted to `WARN` or removed. Cases in `test/rules.test.ts` do not count: they pin the rego, not AWS. Each template is judged in the Region the bench deploys it in (`meta.benchRegion`, else ap-northeast-1), not the harness Region: a block that compares against the deploy Region would otherwise count as measured while the deploy never takes it. The boundary guard also reads the branch templates, so a threshold on a branch is put on its own template. A branch the bundled engine already rejects by itself cannot have a template (the duplication guard refuses it); such a block stays ERROR for older engines and stays on the baseline. By 2026-12-06 the baseline was down to 14 blocks: seven of that kind and the seven of `pf-wafv2-label-syntax`.
238
240
  4. **Real-deploy gate**: `bash bench/verify-rule.sh <rule-id>` deploys the fail template (expects CREATE to fail; records the service error message) and, where cheap, the pass template (expects success, then deletes). Paste the observed error into `meta.yaml#repro.evidence` with the date, then copy the part of it that names the constraint into `meta.yaml#repro.expect` — one line, `expect: "<fragment>"`, no `"` or `\` inside (the monthly runner reads it with `sed`), verbatim from the evidence (`bundle-rules` checks). Every monthly run matches the fail stack's reason against it, so a stack that falls over for anything else is INCONCLUSIVE rather than verified. Required for `real-deploy` rules added on or after 2026-09-27; when the service only ever says something generic (`GeneralServiceException`), quote that. Only `doc-only` rules may skip this, with justification.
239
241
 
240
242
  **A rule about runs after the deploy needs a probe to fail the deploy.** Most resources give CloudFormation nothing to wait on, so the fail template adds a custom resource (logical id `Probe`, type `Custom::CdkpfProbe`) backed by an inline Python function (`ProbeFn`, with its own `ProbeRole`) that, on Create only, runs the resource once — invokes the function, publishes and reads back from the queue, sets the alarm state and reads its history — and answers `FAILED` with what it observed, or `SUCCESS`. The pass template carries the same probe, so the pair differs only in the property the rule judges. `pf-lambda-zipfile-handler-module` and `pf-sns-aws-managed-key-delivery` are the reference implementations. The contract:
package/docs/rules.md CHANGED
@@ -1480,7 +1480,7 @@
1480
1480
  | `pf-ecr-encryption-configuration` | AWS::ECR::Repository<br>AWS::ECR::RepositoryCreationTemplate | KmsKey is only valid with EncryptionType KMS/KMS_DSSE and must live in the deploy region | ERROR | none |
1481
1481
  | `pf-ecr-image-tag-mutability-filters` | AWS::ECR::Repository<br>AWS::ECR::RepositoryCreationTemplate | ImageTagMutabilityExclusionFilters requires a *_WITH_EXCLUSION mutability setting, and vice versa | ERROR | none |
1482
1482
  | `pf-ecr-lifecycle-action` | AWS::ECR::Repository<br>AWS::ECR::RepositoryCreationTemplate | The action type is expire or transition, and transition requires targetStorageClass: archive | ERROR | none |
1483
- | `pf-ecr-lifecycle-count` | AWS::ECR::Repository<br>AWS::ECR::RepositoryCreationTemplate | countUnit belongs to the sinceImage* count types only, countNumber must be positive and storageClass follows countType | ERROR | none |
1483
+ | `pf-ecr-lifecycle-count` | AWS::ECR::Repository<br>AWS::ECR::RepositoryCreationTemplate | countUnit belongs to the sinceImage* count types only, countNumber must be positive (at least 90 for sinceImageTransitioned) and storageClass follows countType | ERROR | none |
1484
1484
  | `pf-ecr-lifecycle-policy-syntax` | AWS::ECR::Repository<br>AWS::ECR::RepositoryCreationTemplate | The lifecycle policy must be a JSON document with 1-50 rules, each holding rulePriority, selection and action and no other keys | ERROR | none |
1485
1485
  | `pf-ecr-lifecycle-rule-priority` | AWS::ECR::Repository<br>AWS::ECR::RepositoryCreationTemplate | rulePriority must be unique and >= 1, and the single tagStatus=any rule must carry the highest priority | ERROR | none |
1486
1486
  | `pf-ecr-lifecycle-tag-status` | AWS::ECR::Repository<br>AWS::ECR::RepositoryCreationTemplate | tagStatus=tagged needs exactly one of tagPrefixList / tagPatternList, tagStatus=untagged or any takes neither | ERROR | none |
package/lib/index.js CHANGED
@@ -19,7 +19,7 @@ const rules_generated_1 = require("./rules.generated");
19
19
  * Preflight.apply(app);
20
20
  */
21
21
  class Preflight {
22
- static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-preflight.Preflight", version: "1.31.0" };
22
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-preflight.Preflight", version: "1.31.1" };
23
23
  /**
24
24
  * Register the cdk-preflight rules on an App or Stage.
25
25
  */