cdk-preflight 1.24.1 → 1.25.0

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.24.1",
10115
- "fingerprint": "1GlAtg4QtS0oMy6iVzd+EOoWl3Y2IQJl0QCOTLxaPco="
10114
+ "version": "1.25.0",
10115
+ "fingerprint": "lqWhQFNsduU2iwqI7HQBITdlXQxVZjkMRSBuX5YyfMk="
10116
10116
  }
package/AGENTS.md CHANGED
@@ -80,6 +80,13 @@ The ordering is by **how easily the L2 guard is bypassed in normal use**, not by
80
80
 
81
81
  The two failure modes are watched separately: **staleness** (the constraint disappeared at AWS — the fail template now deploys clean) is caught by the monthly real-deploy run and reported as BROKEN; **obsolescence** (the engine caught up — the rule is now a duplicate) is caught by the duplication guard and the redundancy scan and reported as REDUNDANT. Both land in the monthly issue.
82
82
 
83
+ **Staleness has a seven-day deadline.** A rule listed under BROKEN is a false positive from the day the run saw its fail template deploy: every user whose template has that shape now gets a synth failure for a deploy that would succeed. Within seven days of the monthly issue, one of two PRs lands for each BROKEN rule:
84
+
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
+ - *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
+
88
+ 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.
89
+
83
90
  **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.
84
91
 
85
92
  **Retiring.** The trigger is the bundled engine starting to block the constraint — never CloudFormation's server-side validation (see the layer table: it blocks the deploy but names no property), never an L2 construct, never cfn-lint. "Block" means the engine reports ERROR/FATAL **at every location the rule reports** on its fail template (same logical id, same or nested property path). An engine error elsewhere in the template does not count: a fail template that lists several cases can have one of them caught by an unrelated engine rule (it happened: E9002 caught the FromPort > ToPort case of `pf-ec2-sg-port-range` and none of its out-of-range cases). You do not have to watch for it; two mechanisms report it:
@@ -121,6 +128,12 @@ A reported false positive (the `false-positive` issue template, label `false-pos
121
128
 
122
129
  3. Fix the rule. `test/rule-table.ts` then checks, for every entry, that the rule stays silent on that template in that Region. Only the rule itself is held to it: the reported shape is kept as it was, so another rule's correct finding on it is not a failure.
123
130
 
131
+ 4. Name the shape. Every false positive fixed so far is one of four: **an omission read as a value** (#392–#405, #454), **a reference read as a literal** (#453, #268, #280), **a rule applied beyond what it measured** (a sibling kind, a branch or a value no fixture reached: #456, #238, #401, the Aurora PostgreSQL ceiling in #461), or **AWS changed** (a raised limit, a newly allowed value: #450, monthly BROKEN). Write the shape in the PR body. One that fits none of them gets a name of its own and is added to this list in the same PR.
132
+ 5. Search the whole pack for the same shape before closing the report, and fix what turns up in the same PR or a follow-up issue. #461 is the model: it took the three fixes of #455 and #459, scanned every rule for their shapes mechanically, read the 186 candidates, and fixed the four that were real.
133
+ 6. Make the shape mechanical. Add the check that would have stopped this report before it shipped (a `lint-rules` pattern, a sweep mode, a fixture requirement), with today's exceptions frozen in a baseline that may only shrink. If no check can see the shape, say why in the rule's rego comment and make the rule `WARN` (principle 8).
134
+
135
+ A report is closed when all six steps are done, not when the rule stops firing on the reported template.
136
+
124
137
  `bundle-rules` fails when a declared issue has no file or a `pass.<n>.template.json` is not declared, so a fixture cannot sit in the directory untested. When one report hits several rules (#394 hit the service and the cluster strategy rules), each rule gets its own copy shaped for its resource type. The first six entries (#238, #392–#395) were back-filled on 2026-12-03 and each was checked to fire on the rule as it was before its fix.
125
138
 
126
139
  ## Repository layout
@@ -215,6 +228,7 @@ If you are a subagent running one of these phases, do not spawn further agents.
215
228
  **Variant sweep (a review aid, not a gate).** `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. The first run over the pack (2026-12-03) listed 2,584 claims from 702 rules, 704 rule/property pairs on properties the rego never names; nearly all are kinds the constraint has nothing to do with (a VPC Lattice CIDR format under `TCP` vs `TCP_UDP`), so the list is read per rule while adding it, not enforced. It only sees `enum` properties: `AWS::CodeBuild::Project.Artifacts.Type` is a plain string in the schema, so the suspect aws-cloudformation-templates turned up there (a constraint measured on `NO_ARTIFACTS`, reported on `CODEPIPELINE`, #456) does not show up.
216
229
 
217
230
  **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).
231
+ **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. The first run (2026-12-05) found 553 such blocks in 295 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, add a resource to the fail template that reaches the block (one fail template may violate several ways), measure it with `bench/verify-rule.sh`, and lower the count. 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.
218
232
  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.
219
233
 
220
234
  **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
@@ -1740,7 +1740,7 @@
1740
1740
  | `pf-elasticbeanstalk-opt-secrets-arn-service` | AWS::ElasticBeanstalk::ConfigurationTemplate<br>AWS::ElasticBeanstalk::Environment | Environment secrets point at Secrets Manager or SSM ARNs | ERROR | none |
1741
1741
  | `pf-elasticbeanstalk-opt-traffic-splitting-alb` | AWS::ElasticBeanstalk::ConfigurationTemplate<br>AWS::ElasticBeanstalk::Environment | TrafficSplitting deployments need an Application Load Balancer | ERROR | none |
1742
1742
  | `pf-elasticbeanstalk-opt-trigger-range` | AWS::ElasticBeanstalk::ConfigurationTemplate<br>AWS::ElasticBeanstalk::Environment | Auto Scaling trigger period, evaluation periods and thresholds are within range | ERROR | none |
1743
- | `pf-elasticbeanstalk-platform-arn-region` | AWS::ElasticBeanstalk::ConfigurationTemplate<br>AWS::ElasticBeanstalk::Environment | An AWS platform ARN must be from the deploy region | ERROR | none |
1743
+ | `pf-elasticbeanstalk-platform-arn-region` | AWS::ElasticBeanstalk::ConfigurationTemplate<br>AWS::ElasticBeanstalk::Environment | An AWS platform ARN must be from the deploy region | WARN | none |
1744
1744
  | `pf-elasticbeanstalk-tmpl-platform-stack-exclusive` | AWS::ElasticBeanstalk::ConfigurationTemplate | PlatformArn and SolutionStackName are mutually exclusive | ERROR | none |
1745
1745
  | `pf-elasticbeanstalk-tmpl-source-required` | AWS::ElasticBeanstalk::ConfigurationTemplate | A ConfigurationTemplate needs a platform, a source template or an environment to start from | ERROR | none |
1746
1746
  | `pf-elbv2-action-cognito-userpool-region` | AWS::ElasticLoadBalancingV2::Listener<br>AWS::ElasticLoadBalancingV2::ListenerRule | The Cognito user pool sits in the load balancer region | ERROR | none |
@@ -2040,7 +2040,7 @@
2040
2040
  | `pf-glue-crawler-non-catalog-target-database-name` | AWS::Glue::Crawler | A crawler with non-catalog targets needs a DatabaseName | ERROR | none |
2041
2041
  | `pf-glue-crawler-recrawl-behavior-s3-only` | AWS::Glue::Crawler | CRAWL_EVENT_MODE and CRAWL_NEW_FOLDERS_ONLY apply to S3 targets only | ERROR | none |
2042
2042
  | `pf-glue-crawler-s3-target-path` | AWS::Glue::Crawler | An S3 crawl target path cannot start with a slash | ERROR | none |
2043
- | `pf-glue-crawler-schedule-cron-only` | AWS::Glue::Crawler | A crawler schedule is a cron() expression | ERROR | pending-engine |
2043
+ | `pf-glue-crawler-schedule-cron-only` | AWS::Glue::Crawler | A crawler schedule is a cron() expression | WARN | pending-engine |
2044
2044
  | `pf-glue-crawler-schedule-day-of-month-or-week` | AWS::Glue::Crawler | A crawler cron needs ? in exactly one of day-of-month and day-of-week | ERROR | none |
2045
2045
  | `pf-glue-crawler-target-connection-name` | AWS::Glue::Crawler | JDBC and MongoDB crawl targets need a connection name | ERROR | none |
2046
2046
  | `pf-glue-custom-entity-type-regex-string-required` | AWS::Glue::CustomEntityType | A custom entity type needs a RegexString | ERROR | pending-engine |
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.24.1" };
22
+ static [JSII_RTTI_SYMBOL_1] = { fqn: "cdk-preflight.Preflight", version: "1.25.0" };
23
23
  /**
24
24
  * Register the cdk-preflight rules on an App or Stage.
25
25
  */