Skip to content

Commit 5a663b9

Browse files
docs(k8s): document infra-pass pattern in CONTRIBUTING.md
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e8030fe commit 5a663b9

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

CONTRIBUTING.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,21 @@ Language support is split between two layers:
8484
4. Add a test case in `tests/test_pipeline.c` for integration-level fixes
8585
5. Verify with a real open-source repo
8686

87+
### Infrastructure Languages (Infra-Pass Pattern)
88+
89+
Languages like **Dockerfile**, **docker-compose**, **Kubernetes manifests**, and **Kustomize** do not use tree-sitter grammars. Instead they follow an *infra-pass* pattern:
90+
91+
1. **Detection helpers** in `src/pipeline/pass_infrascan.c` — functions like `cbm_is_dockerfile()`, `cbm_is_k8s_manifest()`, `cbm_is_kustomize_file()` identify files by name and/or content heuristics (e.g., presence of `apiVersion:`).
92+
2. **Custom extractors** in `src/pipeline/extract_k8s.c` (or `extract_infra.c`) — hand-written parsers that walk the raw YAML/text and populate `CBMFileResult` with imports and definitions.
93+
3. **Pipeline pass** (`pass_k8s.c`, `pass_infrascan.c`) — calls the extractor and emits graph nodes/edges. K8s manifests emit `Resource` nodes; Kustomize files emit `Module` nodes with `IMPORTS` edges to referenced resource files.
94+
95+
**When adding a new infrastructure language:**
96+
- Add a detection helper (`cbm_is_<lang>_file()`) in `pass_infrascan.c` or a new `pass_<lang>.c`.
97+
- Add the `CBM_LANG_<LANG>` enum value in `cbm_language.h` and a row in the language table in `lang_specs.c`.
98+
- Write a custom extractor that returns `CBMFileResult*` — do not add a tree-sitter grammar.
99+
- Register the pass in `pipeline.c`.
100+
- Add tests in `tests/test_pipeline.c` following the `TEST(infra_is_dockerfile)` and `TEST(k8s_extract_manifest)` patterns.
101+
87102
## Pull Request Guidelines
88103

89104
- **C code only** — this project was rewritten from Go to pure C in v0.5.0. Go PRs will be acknowledged and potentially ported, but cannot be merged directly.

0 commit comments

Comments
 (0)