Skip to content

Commit c21e410

Browse files
committed
docs: update documentation for clarity and completeness across multiple files
1 parent a6ee03e commit c21e410

File tree

11 files changed

+39
-197
lines changed

11 files changed

+39
-197
lines changed

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
| **Reference** | | |
1818
| Config schema | [`docs/reference/config-schema.md`](docs/reference/config-schema.md) | Every `CloudBurnConfig` field, defaults, merge behavior |
1919
| Rule IDs | [`docs/reference/rule-ids.md`](docs/reference/rule-ids.md) | ID table, naming convention, presets |
20-
| Finding shape | [`docs/reference/finding-shape.md`](docs/reference/finding-shape.md) | `Finding`, `ResourceLocation`, `ScanResult` type contracts |
20+
| Finding shape | [`docs/reference/finding-shape.md`](docs/reference/finding-shape.md) | `Finding`, `SourceLocation`, `ScanResult` type contracts |
2121
| **Infrastructure** | | |
2222
| Testing | [`docs/TESTING.md`](docs/TESTING.md) | Three-package test strategy, fixtures, TDD flow |
2323
| Turborepo | [`docs/TURBOREPO.md`](docs/TURBOREPO.md) | Task pipeline, boundaries, filtering |

CONTRIBUTING.md

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -24,66 +24,30 @@ pnpm prepare
2424
## Verify Before Opening a PR
2525

2626
```bash
27-
pnpm lint
28-
pnpm typecheck
29-
pnpm test
30-
pnpm build
3127
pnpm verify
3228
```
3329

30+
This runs lint, typecheck, and test across the monorepo.
31+
3432
## Project Boundaries
3533

36-
- `cloudburn` (cli): commands, formatting, exit code behavior.
37-
- `@cloudburn/sdk`: scanner API, engine orchestration, config, parsers, provider adapters.
38-
- `@cloudburn/rules`: rules and presets only (no parser/provider/engine logic).
34+
See [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) for the full package graph and responsibility matrix.
35+
36+
The dependency direction is `cli -> sdk -> rules`. No reverse imports.
3937

4038
## Code Style
4139

4240
- Add TSDoc docstrings to all exports. Document purpose, parameters, and return values.
4341

4442
## Adding a New Rule
4543

46-
1. Choose provider and service path under `packages/rules/src`.
47-
48-
- AWS example: `packages/rules/src/aws/ec2/`
49-
50-
2. Create a rule file using `createRule(...)` from `shared/helpers.ts`.
51-
3. Include mandatory metadata:
52-
53-
- `id`, `name`, `description`, `message`, `provider`, `service`, `supports`
54-
55-
Keep provider discovery, parsers, and cloud SDK calls in `@cloudburn/sdk`. Rule files in
56-
`@cloudburn/rules` should stay pure and expose evaluators over normalized inputs.
57-
58-
4. Export it from service `index.ts` and provider `index.ts`.
59-
5. Ensure preset inclusion when appropriate (`presets/aws-core.ts`).
60-
6. Add or update tests in `packages/rules/test`.
61-
62-
## Rule Metadata Expectations
63-
64-
- IDs use the `CLDBRN-{PROVIDER}-{SERVICE}-{N}` format (uppercase, no zero-padding, sequential per service).
65-
- Keep descriptions user-facing and actionable.
66-
- Keep `message` as the generic public policy text for grouped scan output.
67-
- Prefer `supports: ['iac', 'discovery']` only when both are implemented.
68-
- Use `supports: ['discovery']` or `supports: ['iac']` when a rule only has one real evaluator.
69-
- `CLDBRN-AWS-EBS-1` (`volume-type-current-gen`) is the reference example for a rule supporting both discovery and IaC evaluation.
70-
71-
## Testing Guidance for Rules
72-
73-
- Add metadata/export coverage.
74-
- Add focused unit tests for rule behavior once rule logic is implemented.
75-
- Keep fixtures small and deterministic.
44+
See [`docs/guides/adding-a-rule.md`](docs/guides/adding-a-rule.md) for the full end-to-end walkthrough covering file placement, `createRule`, dataset dependencies, tests, and registration.
7645

7746
## Changesets
7847

79-
Use Changesets for user-facing package changes:
80-
81-
```bash
82-
pnpm changeset
83-
```
48+
Write `.changeset/<slug>.md` files directly for user-facing package changes. Published packages: `cloudburn` (cli), `@cloudburn/sdk`, `@cloudburn/rules`.
8449

85-
Add the generated `.changeset/*.md` file to your PR when it changes a published package
86-
(`cloudburn` (cli), `@cloudburn/sdk`, or `@cloudburn/rules`).
50+
One changeset file per package — never list multiple packages in one file.
8751

8852
Do not run the versioning step in feature PRs. Versioning happens in the automated
8953
release PR on `main`.

docs/REVIEW.md

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,13 @@ Non-obvious conventions and constraints that reviewers must enforce. If a rule h
66

77
## Architecture Boundaries
88

9-
Dependency direction is **`cli -> sdk -> rules`**. No reverse imports.
9+
See [`docs/ARCHITECTURE.md`](ARCHITECTURE.md) for the full package responsibility matrix.
1010

11-
| Package | Owns | Must NOT contain |
12-
| ------------------ | ---------------------------------------------------- | ------------------------------------------------ |
13-
| `cloudburn` (cli) | Commands, formatters, exit codes | Scan logic, rule definitions, config loading |
14-
| `@cloudburn/sdk` | Scanner facade, config, engine, parsers, providers | Rule definitions, CLI concerns |
15-
| `@cloudburn/rules` | Rule declarations, finding types, helpers, presets | I/O, AWS SDK calls, engine logic, config loading |
16-
17-
`@cloudburn/rules` must stay pure — no I/O, no AWS SDK, no engine imports.
11+
Dependency direction is **`cli -> sdk -> rules`**. No reverse imports. `@cloudburn/rules` must stay pure — no I/O, no AWS SDK, no engine imports.
1812

1913
## Finding Shape Gotchas
2014

21-
Output is a three-level hierarchy: `providers -> rules -> findings`.
15+
Output is a three-level hierarchy: `providers -> rules -> findings`. See [`docs/reference/finding-shape.md`](reference/finding-shape.md) for full type contracts.
2216

2317
- `source` (`'discovery' | 'iac'`) and `message` live on the rule group (`Finding`), not on `FindingMatch` or `ScanResult`.
2418
- Evaluators return one grouped `Finding` or `null` — never a flat array, never an empty `findings: []`.
@@ -28,40 +22,33 @@ Output is a three-level hierarchy: `providers -> rules -> findings`.
2822

2923
## Rule Conventions
3024

25+
See [`docs/guides/adding-a-rule.md`](guides/adding-a-rule.md) for the full authoring guide and [`docs/reference/rule-ids.md`](reference/rule-ids.md) for ID conventions.
26+
27+
Key reviewer checks:
28+
3129
- All rules must use `createRule()`.
32-
- Rule IDs follow `CLDBRN-{PROVIDER}-{SERVICE}-{N}`. No zero-padding.
33-
- IDs are permanent — never renumber, even if a rule is removed.
3430
- Rule names describe the policy, not the remediation.
35-
- The canonical `message` is set once on the `Rule` object and must work for both `discovery` and `iac`.
3631
- Only implement evaluators for modes declared in `supports`.
37-
- Static-capable rules with `evaluateStatic` must declare `staticDependencies`.
38-
- Discovery-capable rules with `evaluateLive` must declare `discoveryDependencies`.
3932
- Rules must not declare Terraform type strings, CloudFormation type strings, Resource Explorer `resourceTypes`, or loader wiring directly.
40-
- Static evaluators should read from `StaticEvaluationContext.resources.get('<dataset-key>')`.
41-
- Discovery evaluators should read from `LiveEvaluationContext.resources.get('<dataset-key>')`.
4233

4334
## Testing Layers
4435

45-
Vitest across all three packages. When adding or modifying a rule, all three test layers must be updated:
36+
See [`docs/TESTING.md`](TESTING.md) for the full test strategy and mock boundaries.
37+
38+
When adding or modifying a rule, all three `@cloudburn/rules` test layers must be updated:
4639

4740
1. `exports.test.ts`
4841
2. `rule-metadata.test.ts`
4942
3. `{rule-name}.test.ts`
5043

51-
Mock boundaries:
52-
53-
| Package | What to mock |
54-
| ------------------ | ---------------------------------------------------------------------------------------------------------------- |
55-
| `@cloudburn/rules` | Nothing — pure unit tests |
56-
| `@cloudburn/sdk` | Static dataset loaders/orchestration seams, Resource Explorer catalog helpers, discovery hydrators, `loadConfig` |
57-
| `cloudburn` (cli) | `CloudBurnClient.scanStatic()` / `.discover()` |
58-
5944
## Build Pipeline
6045

61-
`pnpm verify` = `pnpm lint && pnpm typecheck && pnpm test`. This is the gate before committing.
46+
`pnpm verify` is the gate before committing.
6247

6348
## Formatter and Exit Code Contract
6449

50+
See [`docs/architecture/cli.md`](architecture/cli.md) for the full exit-code table and formatter pipeline.
51+
6552
All stdout-producing commands should build a typed `CliResponse` and render it through the shared `renderResponse(response, format)` pipeline.
6653

6754
Supported stdout formats are `json` and `table` only.
@@ -70,14 +57,6 @@ Supported stdout formats are `json` and `table` only.
7057
- `table` output should remain stable ASCII tables, including `rules list`.
7158
- Runtime errors should continue to emit the JSON `stderr` envelope rather than following the selected stdout format.
7259

73-
Exit codes:
74-
75-
- `0` — clean scan, or `--exit-code` not passed
76-
- `1` — findings exist and `--exit-code` was passed
77-
- `2` — runtime error
78-
79-
`--exit-code` counts nested matches across all providers and rules.
80-
8160
## Config System
8261

8362
- `.cloudburn.yml` and `.cloudburn.yaml` are both supported; treat both present in one directory as a real bug.

docs/TURBOREPO.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ packages/
1313

1414
## Dependency Graph
1515

16-
```text
17-
cloudburn -> @cloudburn/sdk -> @cloudburn/rules
18-
```
16+
See [`docs/ARCHITECTURE.md`](ARCHITECTURE.md) for the full package graph and responsibility matrix.
1917

2018
## Root Scripts
2119

docs/architecture/cli.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ graph TD
1212
Root --> Completion["completion"]
1313
Rules --> RulesList["list"]
1414
Discover --> DiscoverInit["init"]
15+
Discover --> DiscoverStatus["status"]
1516
Discover --> DiscoverTypes["supported-resource-types"]
1617
Completion --> CompletionBash["bash"]
1718
Completion --> CompletionFish["fish"]
@@ -51,6 +52,7 @@ All stdout-producing commands return a typed `CliResponse` and share the same fo
5152
- `discover --region <region>` overrides the current AWS region resolved from `AWS_REGION`, `AWS_DEFAULT_REGION`, `aws_region`, then the AWS SDK region provider chain.
5253
- The CLI targets one explicit AWS region per discover run.
5354
- Multi-region discovery remains an SDK capability through `target: { mode: 'regions', regions: [...] }` and requires a Resource Explorer aggregator index.
55+
- `discover status` reports the current Resource Explorer index state and uses the shared `json|table` renderer.
5456
- `discover supported-resource-types` uses the shared `json|table` renderer.
5557
- `discover init` bootstraps Resource Explorer through the SDK, defaults to the current AWS region, accepts `--region <region>` as an override, and falls back to local-only setup when cross-region bootstrap is denied.
5658
- `discover init` status output includes the resolved setup `indexType` so users can distinguish local-only setup from aggregator setup.

docs/architecture/rules.md

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ classDiagram
5858
StaticEvaluationContext --> StaticResourceBag : contains
5959
```
6060

61-
Rules now return a single grouped `Finding` or `null`. The SDK is responsible for regrouping those rule findings under providers in the public `ScanResult`.
61+
Rules return a single grouped `Finding` or `null`. The SDK regroups those rule findings under providers in the public `ScanResult`.
6262

6363
## Rule Assembly Chain
6464

@@ -73,56 +73,8 @@ graph LR
7373

7474
## Authoring Rules
7575

76-
1. Use `createRule({ ... })`.
77-
2. Keep the stable rule metadata, including the canonical public `message`, on the `Rule` object itself.
78-
3. For static IaC rules, declare `staticDependencies` dataset keys.
79-
4. For live AWS rules, declare `discoveryDependencies` dataset keys.
80-
5. Build lean resource-level `FindingMatch` values inside the evaluator.
81-
6. Return `{ ruleId, service, source, message, findings }` when there are matches.
82-
7. Return `null` when nothing matches.
83-
84-
Rule evaluators consume static and live datasets through `context.resources.get('<dataset-key>')`. Rules should not declare Terraform resource type strings, CloudFormation type strings, Resource Explorer `resourceTypes`, or loader wiring directly.
85-
86-
## ID Convention
87-
88-
- **Rule ID:** `CLDBRN-{PROVIDER}-{SERVICE}-{N}`
89-
- Rule IDs remain stable and drive presets, configuration, and public scan output.
90-
- There are no per-resource finding IDs in the public rules contract anymore.
76+
See [`docs/guides/adding-a-rule.md`](../guides/adding-a-rule.md) for the full end-to-end guide and [`docs/reference/rule-ids.md`](../reference/rule-ids.md) for the ID convention and complete rule table.
9177

9278
## Current Rules
9379

94-
| ID | Name | Service | Supports | Status |
95-
| ------------------------- | ------------------------------------------ | ---------- | -------------- | ----------- |
96-
| `CLDBRN-AWS-CLOUDTRAIL-1` | CloudTrail Redundant Global Trails | cloudtrail | discovery | Implemented |
97-
| `CLDBRN-AWS-CLOUDTRAIL-2` | CloudTrail Redundant Regional Trails | cloudtrail | discovery | Implemented |
98-
| `CLDBRN-AWS-CLOUDWATCH-1` | CloudWatch Log Group Missing Retention | cloudwatch | discovery | Implemented |
99-
| `CLDBRN-AWS-CLOUDWATCH-2` | CloudWatch Log Group Inactive | cloudwatch | discovery | Implemented |
100-
| `CLDBRN-AWS-EC2-1` | EC2 Instance Type Not Preferred | ec2 | iac, discovery | Implemented |
101-
| `CLDBRN-AWS-EC2-2` | S3 Interface VPC Endpoint Used | ec2 | iac | Implemented |
102-
| `CLDBRN-AWS-EC2-3` | Elastic IP Address Unassociated | ec2 | discovery | Implemented |
103-
| `CLDBRN-AWS-EC2-4` | VPC Interface Endpoint Inactive | ec2 | discovery | Implemented |
104-
| `CLDBRN-AWS-EC2-5` | EC2 Instance Low Utilization | ec2 | discovery | Implemented |
105-
| `CLDBRN-AWS-EC2-10` | EC2 Instance Detailed Monitoring Enabled | ec2 | iac | Implemented |
106-
| `CLDBRN-AWS-EC2-11` | NAT Gateway Idle | ec2 | discovery | Implemented |
107-
| `CLDBRN-AWS-EBS-1` | EBS Volume Type Not Current Generation | ebs | discovery, iac | Implemented |
108-
| `CLDBRN-AWS-EBS-2` | EBS Volume Unattached | ebs | discovery | Implemented |
109-
| `CLDBRN-AWS-EBS-3` | EBS Volume Attached To Stopped Instances | ebs | discovery | Implemented |
110-
| `CLDBRN-AWS-EBS-4` | EBS Volume Large Size | ebs | discovery | Implemented |
111-
| `CLDBRN-AWS-EBS-5` | EBS Volume High Provisioned IOPS | ebs | discovery | Implemented |
112-
| `CLDBRN-AWS-EBS-6` | EBS Volume Low Provisioned IOPS On io1/io2 | ebs | discovery | Implemented |
113-
| `CLDBRN-AWS-EBS-7` | EBS Snapshot Max Age Exceeded | ebs | discovery | Implemented |
114-
| `CLDBRN-AWS-ECR-1` | ECR Repository Missing Lifecycle Policy | ecr | iac, discovery | Implemented |
115-
| `CLDBRN-AWS-RDS-1` | RDS Instance Class Not Preferred | rds | iac, discovery | Implemented |
116-
| `CLDBRN-AWS-RDS-2` | RDS DB Instance Idle | rds | discovery | Implemented |
117-
| `CLDBRN-AWS-S3-1` | S3 Missing Lifecycle Configuration | s3 | iac, discovery | Implemented |
118-
| `CLDBRN-AWS-S3-2` | S3 Bucket Storage Class Not Optimized | s3 | iac, discovery | Implemented |
119-
| `CLDBRN-AWS-SAGEMAKER-1` | SageMaker Notebook Instance Running | sagemaker | discovery | Implemented |
120-
| `CLDBRN-AWS-LAMBDA-1` | Lambda Cost Optimal Architecture | lambda | iac, discovery | Implemented |
121-
122-
`CLDBRN-AWS-LAMBDA-1` is an advisory rule. It recommends `arm64` only when compatibility is known or explicitly declared, and the static evaluator skips computed or otherwise unknown architecture values instead of treating them as definite `x86_64`.
123-
124-
CloudTrail and CloudWatch discovery rules now rely on dedicated live datasets. CloudBurn seeds both CloudWatch datasets from Resource Explorer `logs:log-group` catalog results, then uses narrow CloudWatch Logs APIs to hydrate group retention metadata and enumerate log streams.
125-
126-
EBS discovery rules now reuse the shared `aws-ebs-volumes` dataset for storage type, attachment, size, and IOPS checks, and use a dedicated `aws-ebs-snapshots` dataset seeded from Resource Explorer `ec2:snapshot` resources for snapshot-age review.
127-
128-
NAT gateway and SageMaker notebook discovery follow the same catalog-first model: CloudBurn seeds NAT review from `ec2:natgateway` resources and hydrates 7-day traffic totals with `DescribeNatGateways` plus CloudWatch metrics, while SageMaker notebook review is seeded from `sagemaker:notebook-instance` resources and hydrated through `DescribeNotebookInstance`.
80+
See [`docs/reference/rule-ids.md`](../reference/rule-ids.md) for the complete rule table with descriptions and support modes.

0 commit comments

Comments
 (0)