Skip to content

Commit b99703a

Browse files
aksOpsclaude
andcommitted
docs: add pipeline configuration & discovery spec
Config-driven predictable pipeline — users configure languages, detectors, parsers, and excludes. CLI discovery via plugins list/info/languages/suggest/docs commands. @DetectorInfo annotation as single source of truth. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7c5573a commit b99703a

1 file changed

Lines changed: 385 additions & 0 deletions

File tree

Lines changed: 385 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,385 @@
1+
# Pipeline Configuration & Discovery Design
2+
3+
**Date:** 2026-03-29
4+
**Status:** Approved
5+
**Scope:** Config-driven predictable pipeline, detector metadata annotation, CLI discovery commands
6+
7+
## Problem
8+
9+
The current pipeline auto-detects everything at runtime — CPU cores, languages, parsers, minified files, modules. Each auto-detect costs CPU cycles. For CI pipelines that scan the same repo repeatedly, this is wasted work.
10+
11+
Users who know their repo should be able to configure exactly what runs, skipping everything irrelevant.
12+
13+
## Principle
14+
15+
**If the user KNOWS, let them tell us. If they don't, auto-detect.**
16+
17+
Config-driven mode = maximum CPU efficiency. No config = backward compatible auto-detect.
18+
19+
## .osscodeiq.yml — Pipeline Configuration
20+
21+
```yaml
22+
# Pipeline performance tuning
23+
pipeline:
24+
parallelism: 2 # Fixed thread count (default: auto-detect from CPU)
25+
batch-size: 500 # Files per H2 flush batch (default: 500)
26+
27+
# Only scan these languages — everything else skipped at file discovery
28+
# If omitted: auto-detect from file extensions (current behavior)
29+
languages:
30+
- java
31+
- kotlin
32+
- typescript
33+
- yaml
34+
- json
35+
36+
# Only run these detector categories
37+
# If omitted: run all detectors (current behavior)
38+
detectors:
39+
categories:
40+
- endpoints
41+
- entities
42+
- auth
43+
- config
44+
- infra
45+
# OR explicit detector names:
46+
# include:
47+
# - java/spring_rest
48+
# - java/jpa_entity
49+
# - python/fastapi_routes
50+
51+
# Explicit parser assignment — no fallback chains
52+
# If omitted: auto-select (JavaParser for java, ANTLR for python/go/etc, regex for rest)
53+
parsers:
54+
java: javaparser
55+
typescript: regex
56+
python: antlr
57+
go: antlr
58+
yaml: structured
59+
60+
# Explicit excludes — no runtime heuristics
61+
exclude:
62+
- "**/*.min.js"
63+
- "**/*.bundle.js"
64+
- "**/*.chunk.js"
65+
- "**/node_modules/**"
66+
- "**/build/**"
67+
- "**/dist/**"
68+
- "**/vendor/**"
69+
- "**/.git/**"
70+
71+
# Topology connections (for service topology feature)
72+
topology:
73+
connections:
74+
- CALLS
75+
- PRODUCES
76+
- CONSUMES
77+
- QUERIES
78+
- CONNECTS_TO
79+
```
80+
81+
## What Each Config Controls
82+
83+
### `languages` — File Discovery Filter
84+
85+
```
86+
Without config: 50K files → all enter pipeline → extension mapping per file
87+
With config: 50K files → filter to configured extensions → 30K enter pipeline
88+
```
89+
20K files never read, never hashed, never passed to detectors.
90+
91+
### `detectors.categories` — Detector Filter
92+
93+
```
94+
Without config: 97 detectors instantiated, all run per file
95+
With config: 12 detectors instantiated, only relevant ones run
96+
```
97+
85 detector invocations skipped per file. On 30K files = 2.5M skipped calls.
98+
99+
### `parsers` — Parser Assignment
100+
101+
```
102+
Without config: Try ANTLR → parse fails → fall back to regex (CPU wasted on failed parse)
103+
With config: Use assigned parser directly, no fallback chain
104+
```
105+
No double-parsing. Every parse attempt succeeds or doesn't happen.
106+
107+
### `pipeline.parallelism` — Thread Count
108+
109+
```
110+
Without config: Runtime.getRuntime().availableProcessors() (auto-detect)
111+
With config: Fixed value, no detection overhead
112+
```
113+
114+
### `exclude` — Skip Patterns
115+
116+
```
117+
Without config: Read file → check if minified (scan content) → maybe skip
118+
With config: Match glob at file discovery → skip immediately, never read
119+
```
120+
No content scanning for minified detection on excluded files.
121+
122+
## @DetectorInfo Annotation
123+
124+
Single source of truth for detector metadata. Every detector declares what it does:
125+
126+
```java
127+
@Target(ElementType.TYPE)
128+
@Retention(RetentionPolicy.RUNTIME)
129+
public @interface DetectorInfo {
130+
String name();
131+
String category();
132+
String description();
133+
ParserType parser() default ParserType.REGEX;
134+
String[] languages();
135+
NodeKind[] nodeKinds();
136+
EdgeKind[] edgeKinds() default {};
137+
String[] properties() default {};
138+
}
139+
140+
public enum ParserType {
141+
REGEX,
142+
JAVAPARSER,
143+
ANTLR,
144+
STRUCTURED
145+
}
146+
```
147+
148+
Usage:
149+
```java
150+
@Component
151+
@DetectorInfo(
152+
name = "spring_rest",
153+
category = "endpoints",
154+
description = "Detects Spring MVC REST endpoints (@GetMapping, @PostMapping, etc.)",
155+
parser = ParserType.JAVAPARSER,
156+
languages = {"java"},
157+
nodeKinds = {NodeKind.ENDPOINT},
158+
edgeKinds = {EdgeKind.EXPOSES},
159+
properties = {"http_method", "path", "produces", "consumes", "framework"}
160+
)
161+
public class SpringRestDetector extends AbstractJavaParserDetector { ... }
162+
```
163+
164+
## Detector Categories
165+
166+
| Category | What it finds | Detectors |
167+
|---|---|---|
168+
| `endpoints` | REST, gRPC, WebSocket, GraphQL endpoints | spring_rest, fastapi_routes, express_routes, nestjs_controllers, jaxrs, etc. |
169+
| `entities` | Database entities, ORM models | jpa_entity, sqlalchemy_models, typeorm_entities, mongoose_orm, django_models, etc. |
170+
| `auth` | Authentication and authorization | spring_security, fastapi_auth, nestjs_guards, passport_jwt, certificate_auth, ldap_auth, etc. |
171+
| `messaging` | Kafka, RabbitMQ, JMS topics and consumers | kafka, kafka_js, rabbitmq, jms, celery_tasks, etc. |
172+
| `config` | Configuration files, infrastructure | kubernetes, helm_chart, github_actions, gitlab_ci, docker_compose, terraform, etc. |
173+
| `infra` | Infrastructure resources | dockerfile, bicep, cloudformation, etc. |
174+
| `structures` | Classes, interfaces, methods, imports | class_hierarchy, python_structures, typescript_structures, go_structures, etc. |
175+
| `frontend` | UI components and routes | react_components, vue_components, angular_components, frontend_routes, etc. |
176+
| `database` | Database connections, queries | jdbc, raw_sql, cosmos_db, go_orm, efcore, etc. |
177+
178+
## CLI Discovery Commands
179+
180+
### `code-iq plugins list`
181+
182+
```
183+
Category Detectors Description
184+
─────────────────────────────────────────────────────
185+
endpoints 14 REST, gRPC, WebSocket, GraphQL endpoints
186+
entities 10 Database entities, ORM models
187+
auth 8 Authentication and authorization
188+
messaging 7 Kafka, RabbitMQ, JMS, Celery
189+
config 18 K8s, Helm, GHA, GitLab CI, CloudFormation
190+
infra 4 Dockerfile, Terraform, Bicep
191+
structures 12 Classes, interfaces, methods, imports
192+
frontend 6 React, Vue, Angular, Svelte components
193+
database 8 JDBC, SQL, Cosmos DB, Go ORM, EF Core
194+
195+
Total: 97 detectors across 9 categories
196+
```
197+
198+
### `code-iq plugins info <category>`
199+
200+
```
201+
$ code-iq plugins info endpoints
202+
203+
Category: endpoints — REST, gRPC, WebSocket, GraphQL endpoints
204+
205+
spring_rest Java JavaParser Spring MVC @GetMapping, @PostMapping, etc.
206+
spring_events Java JavaParser Spring @EventListener publishers/subscribers
207+
jaxrs Java Regex JAX-RS @Path, @GET, @POST annotations
208+
grpc_service Java Regex gRPC service definitions and stubs
209+
websocket Java Regex Spring WebSocket @MessageMapping
210+
fastapi_routes Python ANTLR FastAPI @app.get(), @router.post() decorators
211+
flask_routes Python ANTLR Flask @app.route() decorators
212+
django_views Python ANTLR Django URL patterns and class-based views
213+
express_routes TS/JS Regex Express router.get(), app.post() calls
214+
nestjs_controllers TS Regex NestJS @Controller, @Get, @Post decorators
215+
fastify_routes TS/JS Regex Fastify route handlers
216+
remix_routes TS/JS Regex Remix loader/action exports
217+
graphql_resolvers TS/JS Regex GraphQL @Resolver, @Query, @Mutation
218+
actix_web Rust Regex Actix-web #[get], #[post] macros
219+
```
220+
221+
### `code-iq plugins info <category/name>`
222+
223+
```
224+
$ code-iq plugins info endpoints/spring_rest
225+
226+
Name: spring_rest
227+
Category: endpoints
228+
Parser: JavaParser AST (regex fallback)
229+
Languages: java
230+
Description: Detects Spring MVC REST endpoints from @RequestMapping,
231+
@GetMapping, @PostMapping, @PutMapping, @DeleteMapping,
232+
@PatchMapping annotations. Extracts HTTP method, path,
233+
produces/consumes media types, and parameter annotations.
234+
235+
Node kinds: ENDPOINT
236+
Edge kinds: EXPOSES
237+
Properties: http_method, path, produces, consumes, framework, router
238+
239+
Example output:
240+
Node: endpoint:src/main/.../UserController.java:GET:/api/users
241+
Label: GET /api/users
242+
Properties: {http_method: GET, path: /api/users, framework: spring}
243+
```
244+
245+
### `code-iq plugins languages`
246+
247+
```
248+
Language Extensions Detectors Parser
249+
──────────────────────────────────────────────────────────
250+
java .java 28 JavaParser
251+
typescript .ts, .tsx 13 Regex (ANTLR planned)
252+
python .py 11 ANTLR
253+
config/yaml .yaml, .yml 10 Structured (SnakeYAML)
254+
config/json .json 5 Structured (Jackson)
255+
go .go 4 ANTLR
256+
csharp .cs 4 ANTLR
257+
rust .rs 3 ANTLR
258+
kotlin .kt, .kts 3 ANTLR
259+
shell .sh, .bash, .ps1 3 Regex
260+
scala .scala 2 ANTLR
261+
cpp .cpp, .cc, .h 2 ANTLR
262+
terraform .tf, .tfvars 2 Regex
263+
dockerfile Dockerfile 1 Regex
264+
markdown .md 1 Regex
265+
proto .proto 1 Regex
266+
xml .xml, .pom 1 Structured (JAXB)
267+
```
268+
269+
### `code-iq plugins suggest <path>` — The Killer Feature
270+
271+
Scans repo, analyzes file distribution, generates optimized config:
272+
273+
```
274+
$ code-iq plugins suggest /path/to/my-enterprise-app
275+
276+
🔍 Scanning /path/to/my-enterprise-app ...
277+
📁 Found 15,234 files
278+
279+
Language distribution:
280+
java 8,432 files (55%)
281+
typescript 3,201 files (21%)
282+
yaml 892 files (6%)
283+
json 567 files (4%)
284+
kotlin 423 files (3%)
285+
properties 312 files (2%)
286+
other 1,407 files (9%) — would be skipped
287+
288+
Suggested .osscodeiq.yml:
289+
──────────────────────────
290+
pipeline:
291+
parallelism: 4
292+
batch-size: 500
293+
294+
languages:
295+
- java
296+
- typescript
297+
- kotlin
298+
- yaml
299+
- json
300+
- properties
301+
302+
detectors:
303+
categories:
304+
- endpoints
305+
- entities
306+
- auth
307+
- messaging
308+
- config
309+
- structures
310+
311+
exclude:
312+
- "**/node_modules/**"
313+
- "**/build/**"
314+
- "**/dist/**"
315+
- "**/*.min.js"
316+
317+
# Estimated: ~13,827 files analyzed (9% skipped)
318+
# Estimated: ~85 detectors active (12 skipped)
319+
320+
Save to .osscodeiq.yml? [Y/n]
321+
```
322+
323+
### `code-iq plugins docs --format markdown`
324+
325+
Auto-generates full reference documentation from `@DetectorInfo` annotations:
326+
327+
```bash
328+
code-iq plugins docs --format markdown > docs/detector-reference.md
329+
code-iq plugins docs --format json > docs/detector-reference.json
330+
code-iq plugins docs --format yaml > docs/detector-reference.yaml
331+
```
332+
333+
Output: complete detector catalog with categories, descriptions, languages, node/edge kinds, properties. Always matches code — single source of truth.
334+
335+
## Implementation
336+
337+
### DetectorInfo annotation + DetectorRegistry enhancement
338+
339+
1. Create `@DetectorInfo` annotation
340+
2. Add annotation to all 97 detectors
341+
3. Enhance `DetectorRegistry` to read annotations at startup
342+
4. Build category index: `Map<String, List<Detector>>`
343+
344+
### Config-driven pipeline in Analyzer
345+
346+
1. Read `.osscodeiq.yml` at analysis start
347+
2. If `languages` configured → filter file discovery
348+
3. If `detectors.categories` configured → filter detector registry
349+
4. If `parsers` configured → override parser selection per language
350+
5. If `pipeline.parallelism` configured → use fixed thread count
351+
6. If `exclude` configured → apply glob patterns at file discovery
352+
353+
### Enhanced plugins CLI command
354+
355+
1. `list` — reads from DetectorRegistry category index
356+
2. `info` — reads @DetectorInfo annotation for detail
357+
3. `languages` — aggregates from all detectors' language declarations
358+
4. `suggest` — quick file scan + language stats + config generation
359+
5. `docs` — generates full reference doc from annotations
360+
361+
### Testing
362+
363+
- PluginsCommandTest — test all subcommands
364+
- Config-driven pipeline test — verify filtering works
365+
- Suggest command test — verify config generation
366+
367+
## What Changes
368+
369+
| Component | Change |
370+
|---|---|
371+
| `@DetectorInfo` | New annotation |
372+
| All 97 detectors | Add @DetectorInfo annotation |
373+
| `DetectorRegistry` | Read annotations, build category index |
374+
| `Analyzer` | Config-driven filtering (languages, detectors, parsers) |
375+
| `FileDiscovery` | Language + exclude filtering from config |
376+
| `PluginsCommand` | Enhanced: list, info, languages, suggest, docs |
377+
| `.osscodeiq.yml` | New pipeline/detectors/parsers/exclude sections |
378+
379+
## What Doesn't Change
380+
381+
- Detector logic — same detection, just filtered
382+
- Graph model — same nodes/edges
383+
- MCP tools — same
384+
- REST API — same
385+
- Serve — same

0 commit comments

Comments
 (0)