Skip to content

Commit e12145a

Browse files
authored
Merge pull request #913 from sonoflawal/fix/issues-908-909-910-911-cleanup-conventions-deadcode-config
fix: resolve issues #908 #909 #910 #911 — dead code audit, config def…
2 parents e6b0bc9 + 9043dd6 commit e12145a

60 files changed

Lines changed: 492 additions & 68 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,46 @@ make ci-local
182182
- Document behavior changes in code comments and docs.
183183
- Keep PRs small and easy to review.
184184

185-
## 9. Need Help?
185+
### Rust code conventions
186+
187+
- Module names use `snake_case`.
188+
- Public types and functions require doc comments (`///`).
189+
- Do not add `#[allow(dead_code)]` without a comment explaining why the code must stay.
190+
- Unused imports must be removed before merging.
191+
- Feature-gated code that is no longer used should be deleted, not suppressed.
192+
193+
### Documentation conventions
194+
195+
- Documentation files use `kebab-case.md` (e.g., `disk-scaling.md`).
196+
- Files that belong to a topic area go in the matching `docs/<topic>/` subdirectory.
197+
- Root-level docs (`README.md`, `DEVELOPMENT.md`, `CONTRIBUTING.md`) are entry points only — detailed content belongs in `docs/`.
198+
- New doc files must be linked from `docs/README.md` under the appropriate section.
199+
200+
### Script conventions
201+
202+
- Scripts use `kebab-case.sh` (e.g., `setup-mac.sh`).
203+
- Every script must pass `shellcheck -S error`.
204+
- Historical or one-off scripts should be moved to `scripts/archive/` rather than left in the root of `scripts/`.
205+
206+
### Manifest and config conventions
207+
208+
- CRD YAML files follow the `stellar{feature}-crd.yaml` naming pattern under `config/crd/`.
209+
- Example manifests in `examples/` use descriptive, feature-based names — not issue numbers.
210+
- Generated manifests (CRDs, API reference, bundle) must be regenerated from their source before merging. See the [Regenerating Manifests](DEVELOPMENT.md#regenerating-manifests) table in DEVELOPMENT.md.
211+
212+
## 9. Repo Health Checklist
213+
214+
Run through this before marking a PR ready for review:
215+
216+
- [ ] `make ci-local` passes (format + lint + audit + test + build)
217+
- [ ] No new `#[allow(dead_code)]` without an explanatory comment
218+
- [ ] No unused imports in modified files
219+
- [ ] Generated manifests are up to date with their source
220+
- [ ] Shell scripts pass `shellcheck -S error`
221+
- [ ] New doc files are linked from `docs/README.md`
222+
- [ ] Commit messages follow Conventional Commits and include a `Signed-off-by` line
223+
224+
## 10. Need Help?
186225

187226
If you're stuck, open a Draft PR or create an issue to ask for guidance.
188227

CONVENTIONS.md

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# Repository Conventions
2+
3+
This document defines the naming and structural conventions for the Stellar-K8s repository.
4+
Following these conventions keeps the directory tree easy to skim and reduces surprises for
5+
contributors navigating the codebase for the first time.
6+
7+
---
8+
9+
## Directory Layout
10+
11+
```
12+
Stellar-K8s/
13+
├── assets/ Logo and static images
14+
├── benchmarks/ k6 performance tests and baseline results
15+
├── bundle/ OLM bundle (generated — do not hand-edit)
16+
├── charts/ Helm charts
17+
│ └── stellar-operator/
18+
├── config/ Kubernetes manifests and CRDs (see config/README.md)
19+
│ ├── crd/ Generated CRD YAML files
20+
│ ├── samples/ Example resources for testing
21+
│ ├── manifests/ OLM CSV bases and Gatekeeper policies
22+
│ └── dev/ Local dev kubeconfigs (not for production)
23+
├── docs/ All project documentation (see docs/README.md)
24+
├── examples/ Ready-to-use StellarNode manifests
25+
├── monitoring/ Grafana dashboards and Prometheus alert rules
26+
├── policy/ CEL and OPA policies
27+
├── schemas/ JSON schemas
28+
├── scripts/ Operational scripts
29+
│ ├── dev-utils/ Development helper utilities
30+
│ ├── lib/ Shared script library functions
31+
│ └── archive/ Historical one-off scripts (not part of normal workflow)
32+
├── security/ Security policies and SBOM
33+
├── src/ Rust source code
34+
├── tests/ Integration and E2E tests
35+
└── tools/ CLI and utility tools
36+
```
37+
38+
Each top-level directory has a single, obvious purpose. If a new directory is needed, add it
39+
here and keep its name lowercase with hyphens (`kebab-case`).
40+
41+
---
42+
43+
## Naming Rules
44+
45+
### Rust source files and modules
46+
47+
| Element | Convention | Example |
48+
|---|---|---|
49+
| File names | `snake_case.rs` | `disk_scaler.rs` |
50+
| Module directories | `snake_case/` | `rest_api/` |
51+
| Public types and traits | `UpperCamelCase` | `StellarNode` |
52+
| Public functions | `snake_case` | `reconcile_node` |
53+
| Constants | `SCREAMING_SNAKE_CASE` | `STELLAR_NODE_FINALIZER` |
54+
| Feature flags (`#[cfg]`) | `kebab-case` | `rest-api`, `metrics` |
55+
56+
### Documentation files
57+
58+
| Element | Convention | Example |
59+
|---|---|---|
60+
| File names | `kebab-case.md` | `disk-scaling.md` |
61+
| Directory names | `kebab-case/` | `deployment-guides/` |
62+
| Root-level docs | ALL-CAPS.md for repo meta | `README.md`, `CONTRIBUTING.md` |
63+
64+
Documentation files that belong to a topic area go in the matching `docs/<topic>/` subdirectory.
65+
Root-level files (`README.md`, `DEVELOPMENT.md`, `CONTRIBUTING.md`, `CONVENTIONS.md`) are
66+
entry points only — detailed content belongs in `docs/`.
67+
68+
### Shell scripts
69+
70+
| Element | Convention | Example |
71+
|---|---|---|
72+
| File names | `kebab-case.sh` | `setup-mac.sh` |
73+
| Operational scripts | live in `scripts/` | `scripts/validate.sh` |
74+
| Historical / one-off | move to `scripts/archive/` | `scripts/archive/create_batch_2_issues.sh` |
75+
76+
Every script must pass `shellcheck -S error` before merging.
77+
78+
### Kubernetes manifests
79+
80+
| Element | Convention | Example |
81+
|---|---|---|
82+
| CRD files | `stellar{feature}-crd.yaml` | `stellarnode-crd.yaml` |
83+
| Sample files | descriptive, lowercase, hyphens | `test-stellarnode.yaml` |
84+
| Example files | feature-based, no issue numbers | `validator-mainnet.yaml` |
85+
| Helm chart values | `values.yaml` (defaults), `values-ha.yaml` (variants) ||
86+
87+
**CRD naming**: All CRD YAML files under `config/crd/` follow the `stellar{feature}-crd.yaml`
88+
pattern. The resource kind in the file itself uses `UpperCamelCase` (e.g. `StellarNode`).
89+
90+
**Example manifests**: Files in `examples/` use descriptive, feature-based names. Issue numbers
91+
must not appear in filenames — use the feature name instead
92+
(e.g. `advanced-features-compliance-upgrade-scaling.yaml`, not `advanced-features-500-503.yaml`).
93+
94+
---
95+
96+
## File Placement Rules
97+
98+
1. **Source files**: Go in the most specific module directory under `src/`. Do not place new
99+
`.rs` files directly in `src/` unless they are top-level entry points (`main.rs`, `lib.rs`,
100+
`error.rs`, `cli.rs`).
101+
102+
2. **Documentation files**: Go in the matching `docs/<topic>/` subdirectory. New files must be
103+
linked from `docs/README.md` under the appropriate section.
104+
105+
3. **Config files**: Go under `config/` with a clear subdirectory. Use `config/crd/` for CRDs,
106+
`config/samples/` for test resources, and `config/manifests/` for OLM bases.
107+
108+
4. **Scripts**: Operational scripts go in `scripts/`. One-off or historical scripts go in
109+
`scripts/archive/`. Scripts must not live at the repository root.
110+
111+
5. **Generated files**: Never hand-edit generated files. Always regenerate from source.
112+
See the [Regenerating Manifests](DEVELOPMENT.md#regenerating-manifests) table.
113+
114+
---
115+
116+
## Generated vs Hand-Written Files
117+
118+
| File or directory | Hand-written? | Source of truth |
119+
|---|---|---|
120+
| `config/crd/*.yaml` | No | `src/crd/` Rust types |
121+
| `bundle/manifests/*.yaml` | No | `config/manifests/bases/` + operator-sdk |
122+
| `docs/api-reference.md` | No | `src/crd/` + `make generate-api-docs` |
123+
| Shell completions | No | `src/cli.rs` + `make completions` |
124+
| `charts/stellar-operator/values.yaml` | Yes ||
125+
| `config/operator-config.yaml` | Yes ||
126+
| `docs/**/*.md` (other than api-reference) | Yes ||
127+
128+
---
129+
130+
## Enforcement
131+
132+
These conventions are enforced by:
133+
134+
- **Pre-commit hooks** (`shellcheck`, `cargo fmt`, `yamllint`) — run `make pre-commit-install`
135+
- **CI lint step** (`cargo clippy`, `make fmt-check`) — runs on every PR
136+
- **PR checklist** in [CONTRIBUTING.md](CONTRIBUTING.md#9-repo-health-checklist)
137+
138+
If you find a file that violates these conventions and is not covered by the checklist, open
139+
a PR to fix it or add it to the checklist.

DEVELOPMENT.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,4 +713,62 @@ E2E_OPERATOR_IMAGE=stellar-operator:dev # Custom operator image for E2E
713713

714714
---
715715

716+
## Repo Health Checklist
717+
718+
Use this checklist before merging any PR that touches code, scripts, or documentation. It captures the minimum bar to keep the repository clean and navigable.
719+
720+
### Code Quality
721+
722+
- [ ] `make fmt-check` passes (no unformatted Rust code)
723+
- [ ] `make lint` passes (no clippy warnings at the deny level)
724+
- [ ] `make audit` passes or all advisories are reviewed and acknowledged
725+
- [ ] `make test` passes locally
726+
- [ ] No new `#[allow(dead_code)]` attributes added without a comment explaining why
727+
- [ ] No unused `use` imports left in modified files
728+
- [ ] New public functions and types have doc comments
729+
730+
### Documentation
731+
732+
- [ ] Any user-facing behavior change is reflected in `docs/` or the relevant doc file
733+
- [ ] New `make` targets are listed under **Useful Make Targets** in this file
734+
- [ ] New environment variables are listed under **Environment Variables** in the Quick Reference
735+
- [ ] CRD field changes trigger `make generate-api-docs` to regenerate `docs/api-reference.md`
736+
737+
### Scripts and Manifests
738+
739+
- [ ] Shell scripts pass `shellcheck -S error`
740+
- [ ] New config files go under `config/` with a clear subdirectory (see `config/README.md`)
741+
- [ ] Helm values changes are reflected in `charts/stellar-operator/values.yaml` comments
742+
- [ ] Generated manifests are regenerated from their source (see [Regenerating Manifests](#regenerating-manifests))
743+
744+
### Naming
745+
746+
- [ ] Rust modules use `snake_case`
747+
- [ ] Documentation files use `kebab-case.md`
748+
- [ ] CRD YAML files follow the `stellar{feature}-crd.yaml` pattern
749+
- [ ] Example manifests use descriptive names, not issue-number-based names
750+
751+
### Final
752+
753+
- [ ] `make ci-local` passes end-to-end (format + lint + audit + test + build)
754+
- [ ] Branch is up to date with `main`
755+
- [ ] Commit messages follow Conventional Commits
756+
757+
---
758+
759+
## Regenerating Manifests
760+
761+
Several files in this repo are generated from a source of truth. Always regenerate them after changing the source.
762+
763+
| Generated file | Source of truth | Regeneration command |
764+
|---|---|---|
765+
| `docs/api-reference.md` | CRD types in `src/crd/` | `make generate-api-docs` |
766+
| `config/crd/*.yaml` | CRD structs in `src/crd/` | `make crd-gen` |
767+
| `bundle/manifests/*.yaml` | `config/manifests/bases/` + operator metadata | `make bundle` (requires operator-sdk) |
768+
| Shell completions | CLI definitions in `src/cli.rs` | `make completions` |
769+
770+
After running any of the above, commit the updated generated file alongside the source change in the same PR.
771+
772+
---
773+
716774
Happy coding! If you encounter issues not covered here, please open an issue or ask in the community channels.

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,20 @@ featureFlags:
321321

322322
We welcome contributions! This project uses pre-commit hooks to ensure code quality. Please see our [Contributing Guide](CONTRIBUTING.md) for details on our development process, coding standards, and how to submit pull requests.
323323

324+
### Repo Health Checklist
325+
326+
Before opening a PR, run through this quick checklist to keep the repo clean:
327+
328+
- `make ci-local` — runs format check, lint, security audit, tests, and build in one step
329+
- `make fmt` — auto-formats all Rust code
330+
- `make lint` — runs clippy at the deny level
331+
- `make audit` — scans dependencies for known vulnerabilities
332+
- `shellcheck -S error scripts/*.sh` — validates shell scripts
333+
- `make generate-api-docs` — regenerates `docs/api-reference.md` after CRD changes
334+
- `make crd-gen` — regenerates `config/crd/` manifests after CRD type changes
335+
336+
For the full checklist and expected conventions for docs, scripts, and code, see [DEVELOPMENT.md](DEVELOPMENT.md#repo-health-checklist), [CONTRIBUTING.md](CONTRIBUTING.md#9-repo-health-checklist), and [CONVENTIONS.md](CONVENTIONS.md).
337+
324338
### Quick Start for Contributors
325339

326340
```bash

0 commit comments

Comments
 (0)