@mytechtoday/augment-extensions 1.4.0 → 1.5.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/augment-extensions/coding-standards/c/CHANGELOG.md +55 -0
- package/augment-extensions/coding-standards/c/LICENSE +22 -0
- package/augment-extensions/coding-standards/c/README.md +167 -0
- package/augment-extensions/coding-standards/c/config/defaults.json +26 -0
- package/augment-extensions/coding-standards/c/config/examples/embedded.yaml +25 -0
- package/augment-extensions/coding-standards/c/config/examples/systems.json +31 -0
- package/augment-extensions/coding-standards/c/config/schema.json +244 -0
- package/augment-extensions/coding-standards/c/docs/API.md +613 -0
- package/augment-extensions/coding-standards/c/docs/CONFIGURATION.md +259 -0
- package/augment-extensions/coding-standards/c/docs/USER_GUIDE.md +567 -0
- package/augment-extensions/coding-standards/c/examples/drivers/Makefile +33 -0
- package/augment-extensions/coding-standards/c/examples/drivers/README.md +192 -0
- package/augment-extensions/coding-standards/c/examples/drivers/dma-example.c +224 -0
- package/augment-extensions/coding-standards/c/examples/drivers/example.dts +64 -0
- package/augment-extensions/coding-standards/c/examples/drivers/platform-driver.c +174 -0
- package/augment-extensions/coding-standards/c/examples/embedded/README.md +167 -0
- package/augment-extensions/coding-standards/c/examples/embedded/gpio-control.c +172 -0
- package/augment-extensions/coding-standards/c/examples/embedded/timer-isr.c +198 -0
- package/augment-extensions/coding-standards/c/examples/embedded/uart-communication.c +212 -0
- package/augment-extensions/coding-standards/c/examples/kernel/Makefile +82 -0
- package/augment-extensions/coding-standards/c/examples/kernel/README.md +168 -0
- package/augment-extensions/coding-standards/c/examples/kernel/char-device.c +198 -0
- package/augment-extensions/coding-standards/c/examples/kernel/proc-file.c +131 -0
- package/augment-extensions/coding-standards/c/examples/kernel/simple-module.c +111 -0
- package/augment-extensions/coding-standards/c/examples/legacy/Makefile +62 -0
- package/augment-extensions/coding-standards/c/examples/legacy/README.md +255 -0
- package/augment-extensions/coding-standards/c/examples/legacy/c89-to-c11-migration.c +268 -0
- package/augment-extensions/coding-standards/c/examples/legacy/compatibility-layer.c +239 -0
- package/augment-extensions/coding-standards/c/examples/networking/Makefile +35 -0
- package/augment-extensions/coding-standards/c/examples/networking/README.md +207 -0
- package/augment-extensions/coding-standards/c/examples/networking/protocol-parser.c +270 -0
- package/augment-extensions/coding-standards/c/examples/networking/tcp-server.c +197 -0
- package/augment-extensions/coding-standards/c/examples/networking/udp-multicast.c +220 -0
- package/augment-extensions/coding-standards/c/examples/realtime/Makefile +53 -0
- package/augment-extensions/coding-standards/c/examples/realtime/README.md +199 -0
- package/augment-extensions/coding-standards/c/examples/realtime/deadline-monitoring.c +260 -0
- package/augment-extensions/coding-standards/c/examples/realtime/priority-scheduling.c +258 -0
- package/augment-extensions/coding-standards/c/examples/systems/Makefile +34 -0
- package/augment-extensions/coding-standards/c/examples/systems/README.md +123 -0
- package/augment-extensions/coding-standards/c/examples/systems/ipc-pipes.c +181 -0
- package/augment-extensions/coding-standards/c/examples/systems/process-management.c +153 -0
- package/augment-extensions/coding-standards/c/examples/systems/signal-handling.c +162 -0
- package/augment-extensions/coding-standards/c/module.json +149 -0
- package/augment-extensions/coding-standards/c/rules/categories/drivers.md +635 -0
- package/augment-extensions/coding-standards/c/rules/categories/embedded.md +510 -0
- package/augment-extensions/coding-standards/c/rules/categories/kernel.md +653 -0
- package/augment-extensions/coding-standards/c/rules/categories/legacy.md +526 -0
- package/augment-extensions/coding-standards/c/rules/categories/networking.md +735 -0
- package/augment-extensions/coding-standards/c/rules/categories/realtime.md +631 -0
- package/augment-extensions/coding-standards/c/rules/categories/systems.md +586 -0
- package/augment-extensions/coding-standards/c/rules/universal/const-correctness.md +275 -0
- package/augment-extensions/coding-standards/c/rules/universal/documentation.md +251 -0
- package/augment-extensions/coding-standards/c/rules/universal/error-handling.md +250 -0
- package/augment-extensions/coding-standards/c/rules/universal/header-guards.md +254 -0
- package/augment-extensions/coding-standards/c/rules/universal/memory-safety.md +233 -0
- package/augment-extensions/coding-standards/c/rules/universal/naming.md +146 -0
- package/augment-extensions/coding-standards/c/src/conflict-detector.ts +461 -0
- package/augment-extensions/coding-standards/c/src/prompt-generator.ts +307 -0
- package/augment-extensions/coding-standards/c/src/rule-evaluator.ts +307 -0
- package/augment-extensions/coding-standards/c/src/rule-override.ts +427 -0
- package/augment-extensions/coding-standards/c/src/template-engine.ts +217 -0
- package/augment-extensions/coding-standards/c/templates/prompts/drivers.txt +191 -0
- package/augment-extensions/coding-standards/c/templates/prompts/embedded.txt +164 -0
- package/augment-extensions/coding-standards/c/templates/prompts/kernel.txt +175 -0
- package/augment-extensions/coding-standards/c/templates/prompts/legacy.txt +280 -0
- package/augment-extensions/coding-standards/c/templates/prompts/networking.txt +259 -0
- package/augment-extensions/coding-standards/c/templates/prompts/realtime.txt +219 -0
- package/augment-extensions/coding-standards/c/templates/prompts/systems.txt +147 -0
- package/augment-extensions/coding-standards/c/tests/integration/category-specific.test.ts +356 -0
- package/augment-extensions/coding-standards/c/tests/integration/end-to-end-workflow.test.ts +377 -0
- package/augment-extensions/coding-standards/c/tests/performance/benchmarks.test.ts +407 -0
- package/augment-extensions/coding-standards/c/tests/unit/config-manager.test.ts +345 -0
- package/augment-extensions/coding-standards/c/tests/unit/conflict-detector.test.ts +294 -0
- package/augment-extensions/coding-standards/c/tests/unit/prompt-generator.test.ts +174 -0
- package/augment-extensions/coding-standards/c/tests/unit/registry.test.ts +313 -0
- package/augment-extensions/coding-standards/c/tests/unit/rule-evaluator.test.ts +318 -0
- package/augment-extensions/coding-standards/c/tests/unit/rule-override.test.ts +326 -0
- package/augment-extensions/coding-standards/c/tests/unit/template-engine.test.ts +314 -0
- package/augment-extensions/coding-standards/go/CHARACTER-COUNT-REPORT.md +135 -0
- package/augment-extensions/coding-standards/go/PHASE1-COMPLETION.md +146 -0
- package/augment-extensions/coding-standards/go/PHASE4-COMPLETION.md +184 -0
- package/augment-extensions/coding-standards/go/README.md +200 -0
- package/augment-extensions/coding-standards/go/VALIDATION-CHECKLIST.md +154 -0
- package/augment-extensions/coding-standards/go/config/examples/example-cli.json +15 -0
- package/augment-extensions/coding-standards/go/config/examples/example-microservices.json +21 -0
- package/augment-extensions/coding-standards/go/config/examples/example-multi-category.yaml +24 -0
- package/augment-extensions/coding-standards/go/config/examples/example-web.json +15 -0
- package/augment-extensions/coding-standards/go/config/schema.json +110 -0
- package/augment-extensions/coding-standards/go/docs/CATEGORIES.md +221 -0
- package/augment-extensions/coding-standards/go/docs/CONFIGURATION.md +198 -0
- package/augment-extensions/coding-standards/go/docs/TROUBLESHOOTING.md +285 -0
- package/augment-extensions/coding-standards/go/examples/cli/cobra-app.go +287 -0
- package/augment-extensions/coding-standards/go/examples/cloud-native-app.go +217 -0
- package/augment-extensions/coding-standards/go/examples/devops-tool.go +250 -0
- package/augment-extensions/coding-standards/go/examples/distributed-system.go +247 -0
- package/augment-extensions/coding-standards/go/examples/microservices/grpc-service.go +253 -0
- package/augment-extensions/coding-standards/go/examples/rest-api.go +270 -0
- package/augment-extensions/coding-standards/go/examples/web/http-server.go +224 -0
- package/augment-extensions/coding-standards/go/module.json +139 -0
- package/augment-extensions/coding-standards/go/rules/categories/api-development/api-versioning.md +149 -0
- package/augment-extensions/coding-standards/go/rules/categories/api-development/rate-limiting.md +209 -0
- package/augment-extensions/coding-standards/go/rules/categories/api-development/rest-api-design.md +183 -0
- package/augment-extensions/coding-standards/go/rules/categories/cloud-native/cloud-config.md +193 -0
- package/augment-extensions/coding-standards/go/rules/categories/cloud-native/health-checks.md +231 -0
- package/augment-extensions/coding-standards/go/rules/categories/cloud-native/kubernetes.md +180 -0
- package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/automation.md +179 -0
- package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/ci-cd-integration.md +147 -0
- package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/infrastructure-as-code.md +231 -0
- package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/caching.md +150 -0
- package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/consensus.md +187 -0
- package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/event-sourcing.md +246 -0
- package/augment-extensions/coding-standards/go/rules/cli/command-parsing.md +264 -0
- package/augment-extensions/coding-standards/go/rules/cli/configuration.md +268 -0
- package/augment-extensions/coding-standards/go/rules/cli/cross-platform.md +324 -0
- package/augment-extensions/coding-standards/go/rules/microservices/distributed-tracing.md +253 -0
- package/augment-extensions/coding-standards/go/rules/microservices/grpc.md +257 -0
- package/augment-extensions/coding-standards/go/rules/microservices/metrics.md +278 -0
- package/augment-extensions/coding-standards/go/rules/microservices/service-discovery.md +249 -0
- package/augment-extensions/coding-standards/go/rules/universal/code-organization.md +221 -0
- package/augment-extensions/coding-standards/go/rules/universal/documentation.md +269 -0
- package/augment-extensions/coding-standards/go/rules/universal/performance.md +323 -0
- package/augment-extensions/coding-standards/go/rules/universal/testing.md +162 -0
- package/augment-extensions/coding-standards/go/rules/web/graceful-shutdown.md +249 -0
- package/augment-extensions/coding-standards/go/rules/web/http-handlers.md +164 -0
- package/augment-extensions/coding-standards/go/rules/web/middleware.md +234 -0
- package/augment-extensions/coding-standards/go/rules/web/routing.md +251 -0
- package/augment-extensions/coding-standards/go/templates/prompts/api.md +160 -0
- package/augment-extensions/coding-standards/go/templates/prompts/cli.md +225 -0
- package/augment-extensions/coding-standards/go/templates/prompts/cloud-native.md +121 -0
- package/augment-extensions/coding-standards/go/templates/prompts/devops.md +146 -0
- package/augment-extensions/coding-standards/go/templates/prompts/distributed.md +133 -0
- package/augment-extensions/coding-standards/go/templates/prompts/microservices.md +225 -0
- package/augment-extensions/coding-standards/go/templates/prompts/web.md +181 -0
- package/augment-extensions/coding-standards/go/tests/integration/module-integration.test.ts +164 -0
- package/augment-extensions/coding-standards/go/tests/unit/category-selection.test.ts +147 -0
- package/augment-extensions/coding-standards/go/tests/unit/module-structure.test.ts +154 -0
- package/augment-extensions/coding-standards/go/tests/validate-character-count.ps1 +13 -0
- package/augment-extensions/coding-standards/go/tests/validate-examples.ps1 +148 -0
- package/augment-extensions/coding-standards/go/tests/validate-examples.sh +135 -0
- package/cli/dist/analysis/ast-parser.d.ts +47 -0
- package/cli/dist/analysis/ast-parser.d.ts.map +1 -0
- package/cli/dist/analysis/ast-parser.js +161 -0
- package/cli/dist/analysis/ast-parser.js.map +1 -0
- package/cli/dist/analysis/complexity-analyzer.d.ts +27 -0
- package/cli/dist/analysis/complexity-analyzer.d.ts.map +1 -0
- package/cli/dist/analysis/complexity-analyzer.js +189 -0
- package/cli/dist/analysis/complexity-analyzer.js.map +1 -0
- package/cli/dist/analysis/dependency-analyzer.d.ts +23 -0
- package/cli/dist/analysis/dependency-analyzer.d.ts.map +1 -0
- package/cli/dist/analysis/dependency-analyzer.js +237 -0
- package/cli/dist/analysis/dependency-analyzer.js.map +1 -0
- package/cli/dist/analysis/index.d.ts +9 -0
- package/cli/dist/analysis/index.d.ts.map +1 -0
- package/cli/dist/analysis/index.js +25 -0
- package/cli/dist/analysis/index.js.map +1 -0
- package/cli/dist/analysis/security-scanner.d.ts +11 -0
- package/cli/dist/analysis/security-scanner.d.ts.map +1 -0
- package/cli/dist/analysis/security-scanner.js +294 -0
- package/cli/dist/analysis/security-scanner.js.map +1 -0
- package/cli/dist/analysis/types.d.ts +151 -0
- package/cli/dist/analysis/types.d.ts.map +1 -0
- package/cli/dist/analysis/types.js +6 -0
- package/cli/dist/analysis/types.js.map +1 -0
- package/cli/dist/cli.js +24 -0
- package/cli/dist/cli.js.map +1 -1
- package/cli/dist/commands/code-analysis.d.ts +11 -0
- package/cli/dist/commands/code-analysis.d.ts.map +1 -0
- package/cli/dist/commands/code-analysis.js +412 -0
- package/cli/dist/commands/code-analysis.js.map +1 -0
- package/modules.md +99 -3
- package/package.json +14 -2
- package/cli/dist/commands/agent.d.ts +0 -37
- package/cli/dist/commands/agent.d.ts.map +0 -1
- package/cli/dist/commands/agent.js +0 -222
- package/cli/dist/commands/agent.js.map +0 -1
- package/cli/dist/commands/beads.d.ts +0 -64
- package/cli/dist/commands/beads.d.ts.map +0 -1
- package/cli/dist/commands/beads.js +0 -377
- package/cli/dist/commands/beads.js.map +0 -1
- package/cli/dist/commands/change.d.ts +0 -54
- package/cli/dist/commands/change.d.ts.map +0 -1
- package/cli/dist/commands/change.js +0 -243
- package/cli/dist/commands/change.js.map +0 -1
- package/cli/dist/commands/clean.d.ts +0 -15
- package/cli/dist/commands/clean.d.ts.map +0 -1
- package/cli/dist/commands/clean.js +0 -63
- package/cli/dist/commands/clean.js.map +0 -1
- package/cli/dist/commands/clone.d.ts +0 -15
- package/cli/dist/commands/clone.d.ts.map +0 -1
- package/cli/dist/commands/clone.js +0 -49
- package/cli/dist/commands/clone.js.map +0 -1
- package/cli/dist/commands/config.d.ts +0 -33
- package/cli/dist/commands/config.d.ts.map +0 -1
- package/cli/dist/commands/config.js +0 -166
- package/cli/dist/commands/config.js.map +0 -1
- package/cli/dist/commands/context.d.ts +0 -38
- package/cli/dist/commands/context.d.ts.map +0 -1
- package/cli/dist/commands/context.js +0 -205
- package/cli/dist/commands/context.js.map +0 -1
- package/cli/dist/commands/create.d.ts +0 -18
- package/cli/dist/commands/create.d.ts.map +0 -1
- package/cli/dist/commands/create.js +0 -178
- package/cli/dist/commands/create.js.map +0 -1
- package/cli/dist/commands/diff.d.ts +0 -19
- package/cli/dist/commands/diff.d.ts.map +0 -1
- package/cli/dist/commands/diff.js +0 -104
- package/cli/dist/commands/diff.js.map +0 -1
- package/cli/dist/commands/doctor.d.ts +0 -14
- package/cli/dist/commands/doctor.d.ts.map +0 -1
- package/cli/dist/commands/doctor.js +0 -62
- package/cli/dist/commands/doctor.js.map +0 -1
- package/cli/dist/commands/export.d.ts +0 -28
- package/cli/dist/commands/export.d.ts.map +0 -1
- package/cli/dist/commands/export.js +0 -135
- package/cli/dist/commands/export.js.map +0 -1
- package/cli/dist/commands/import.d.ts +0 -23
- package/cli/dist/commands/import.d.ts.map +0 -1
- package/cli/dist/commands/import.js +0 -118
- package/cli/dist/commands/import.js.map +0 -1
- package/cli/dist/commands/prompt.d.ts +0 -45
- package/cli/dist/commands/prompt.d.ts.map +0 -1
- package/cli/dist/commands/prompt.js +0 -223
- package/cli/dist/commands/prompt.js.map +0 -1
- package/cli/dist/commands/spec.d.ts +0 -57
- package/cli/dist/commands/spec.d.ts.map +0 -1
- package/cli/dist/commands/spec.js +0 -279
- package/cli/dist/commands/spec.js.map +0 -1
- package/cli/dist/commands/stats.d.ts +0 -18
- package/cli/dist/commands/stats.d.ts.map +0 -1
- package/cli/dist/commands/stats.js +0 -85
- package/cli/dist/commands/stats.js.map +0 -1
- package/cli/dist/commands/task.d.ts +0 -65
- package/cli/dist/commands/task.d.ts.map +0 -1
- package/cli/dist/commands/task.js +0 -282
- package/cli/dist/commands/task.js.map +0 -1
- package/cli/dist/commands/template.d.ts +0 -17
- package/cli/dist/commands/template.d.ts.map +0 -1
- package/cli/dist/commands/template.js +0 -55
- package/cli/dist/commands/template.js.map +0 -1
- package/cli/dist/utils/agent-config.d.ts +0 -129
- package/cli/dist/utils/agent-config.d.ts.map +0 -1
- package/cli/dist/utils/agent-config.js +0 -297
- package/cli/dist/utils/agent-config.js.map +0 -1
- package/cli/dist/utils/beads-graph.d.ts +0 -17
- package/cli/dist/utils/beads-graph.d.ts.map +0 -1
- package/cli/dist/utils/beads-graph.js +0 -150
- package/cli/dist/utils/beads-graph.js.map +0 -1
- package/cli/dist/utils/beads-integration.d.ts +0 -112
- package/cli/dist/utils/beads-integration.d.ts.map +0 -1
- package/cli/dist/utils/beads-integration.js +0 -312
- package/cli/dist/utils/beads-integration.js.map +0 -1
- package/cli/dist/utils/beads-reporter.d.ts +0 -17
- package/cli/dist/utils/beads-reporter.d.ts.map +0 -1
- package/cli/dist/utils/beads-reporter.js +0 -160
- package/cli/dist/utils/beads-reporter.js.map +0 -1
- package/cli/dist/utils/cache-manager.d.ts +0 -55
- package/cli/dist/utils/cache-manager.d.ts.map +0 -1
- package/cli/dist/utils/cache-manager.js +0 -150
- package/cli/dist/utils/cache-manager.js.map +0 -1
- package/cli/dist/utils/change-manager.d.ts +0 -70
- package/cli/dist/utils/change-manager.d.ts.map +0 -1
- package/cli/dist/utils/change-manager.js +0 -412
- package/cli/dist/utils/change-manager.js.map +0 -1
- package/cli/dist/utils/config-manager-enhanced.d.ts +0 -66
- package/cli/dist/utils/config-manager-enhanced.d.ts.map +0 -1
- package/cli/dist/utils/config-manager-enhanced.js +0 -77
- package/cli/dist/utils/config-manager-enhanced.js.map +0 -1
- package/cli/dist/utils/context-manager.d.ts +0 -96
- package/cli/dist/utils/context-manager.d.ts.map +0 -1
- package/cli/dist/utils/context-manager.js +0 -258
- package/cli/dist/utils/context-manager.js.map +0 -1
- package/cli/dist/utils/diff-engine.d.ts +0 -78
- package/cli/dist/utils/diff-engine.d.ts.map +0 -1
- package/cli/dist/utils/diff-engine.js +0 -233
- package/cli/dist/utils/diff-engine.js.map +0 -1
- package/cli/dist/utils/export-system.d.ts +0 -101
- package/cli/dist/utils/export-system.d.ts.map +0 -1
- package/cli/dist/utils/export-system.js +0 -289
- package/cli/dist/utils/export-system.js.map +0 -1
- package/cli/dist/utils/health-checker.d.ts +0 -66
- package/cli/dist/utils/health-checker.d.ts.map +0 -1
- package/cli/dist/utils/health-checker.js +0 -285
- package/cli/dist/utils/health-checker.js.map +0 -1
- package/cli/dist/utils/import-system.d.ts +0 -74
- package/cli/dist/utils/import-system.d.ts.map +0 -1
- package/cli/dist/utils/import-system.js +0 -317
- package/cli/dist/utils/import-system.js.map +0 -1
- package/cli/dist/utils/module-cloner.d.ts +0 -40
- package/cli/dist/utils/module-cloner.d.ts.map +0 -1
- package/cli/dist/utils/module-cloner.js +0 -136
- package/cli/dist/utils/module-cloner.js.map +0 -1
- package/cli/dist/utils/prompt-manager.d.ts +0 -90
- package/cli/dist/utils/prompt-manager.d.ts.map +0 -1
- package/cli/dist/utils/prompt-manager.js +0 -302
- package/cli/dist/utils/prompt-manager.js.map +0 -1
- package/cli/dist/utils/spec-manager.d.ts +0 -65
- package/cli/dist/utils/spec-manager.d.ts.map +0 -1
- package/cli/dist/utils/spec-manager.js +0 -329
- package/cli/dist/utils/spec-manager.js.map +0 -1
- package/cli/dist/utils/stats-collector.d.ts +0 -74
- package/cli/dist/utils/stats-collector.d.ts.map +0 -1
- package/cli/dist/utils/stats-collector.js +0 -164
- package/cli/dist/utils/stats-collector.js.map +0 -1
- package/cli/dist/utils/template-engine.d.ts +0 -47
- package/cli/dist/utils/template-engine.d.ts.map +0 -1
- package/cli/dist/utils/template-engine.js +0 -204
- package/cli/dist/utils/template-engine.js.map +0 -1
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conflict Detector for C Coding Standards
|
|
3
|
+
*
|
|
4
|
+
* Detects conflicts between overlapping rules and provides resolution suggestions.
|
|
5
|
+
* Handles contradictory requirements and rule precedence.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Rule, Category, Configuration } from './types';
|
|
9
|
+
import { RuleRegistry } from './registry';
|
|
10
|
+
import { ConfigurationManager } from './config-manager';
|
|
11
|
+
|
|
12
|
+
export type ConflictType = 'direct' | 'implicit' | 'precedence' | 'scope';
|
|
13
|
+
export type ConflictSeverity = 'high' | 'medium' | 'low';
|
|
14
|
+
|
|
15
|
+
export interface RuleConflict {
|
|
16
|
+
type: ConflictType;
|
|
17
|
+
severity: ConflictSeverity;
|
|
18
|
+
rule1: Rule;
|
|
19
|
+
rule2: Rule;
|
|
20
|
+
description: string;
|
|
21
|
+
reason: string;
|
|
22
|
+
suggestion: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ConflictResolution {
|
|
26
|
+
conflict: RuleConflict;
|
|
27
|
+
resolution: 'use_rule1' | 'use_rule2' | 'merge' | 'user_decision';
|
|
28
|
+
rationale: string;
|
|
29
|
+
appliedRule?: Rule;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ConflictReport {
|
|
33
|
+
conflicts: RuleConflict[];
|
|
34
|
+
resolutions: ConflictResolution[];
|
|
35
|
+
summary: {
|
|
36
|
+
total: number;
|
|
37
|
+
high: number;
|
|
38
|
+
medium: number;
|
|
39
|
+
low: number;
|
|
40
|
+
resolved: number;
|
|
41
|
+
unresolved: number;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export class ConflictDetector {
|
|
46
|
+
constructor(
|
|
47
|
+
private registry: RuleRegistry,
|
|
48
|
+
private configManager: ConfigurationManager
|
|
49
|
+
) {}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Detect all conflicts in the rule set
|
|
53
|
+
*/
|
|
54
|
+
detectConflicts(categories?: Category[]): ConflictReport {
|
|
55
|
+
const config = this.configManager.getConfiguration();
|
|
56
|
+
const activeCategories = categories || config.c_standards.categories;
|
|
57
|
+
|
|
58
|
+
// Get all active rules for the specified categories
|
|
59
|
+
const rules = this.registry.queryRules({
|
|
60
|
+
categories: activeCategories,
|
|
61
|
+
enabled: true
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const conflicts: RuleConflict[] = [];
|
|
65
|
+
|
|
66
|
+
// Check each pair of rules for conflicts
|
|
67
|
+
for (let i = 0; i < rules.length; i++) {
|
|
68
|
+
for (let j = i + 1; j < rules.length; j++) {
|
|
69
|
+
const conflict = this.checkRulePair(rules[i], rules[j]);
|
|
70
|
+
if (conflict) {
|
|
71
|
+
conflicts.push(conflict);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Generate resolutions
|
|
77
|
+
const resolutions = conflicts.map(conflict =>
|
|
78
|
+
this.resolveConflict(conflict, config)
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
// Generate summary
|
|
82
|
+
const summary = this.generateSummary(conflicts, resolutions);
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
conflicts,
|
|
86
|
+
resolutions,
|
|
87
|
+
summary
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Check if two rules conflict
|
|
93
|
+
*/
|
|
94
|
+
private checkRulePair(rule1: Rule, rule2: Rule): RuleConflict | null {
|
|
95
|
+
// Check for direct conflicts (contradictory requirements)
|
|
96
|
+
const directConflict = this.checkDirectConflict(rule1, rule2);
|
|
97
|
+
if (directConflict) {
|
|
98
|
+
return directConflict;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Check for implicit conflicts (incompatible states)
|
|
102
|
+
const implicitConflict = this.checkImplicitConflict(rule1, rule2);
|
|
103
|
+
if (implicitConflict) {
|
|
104
|
+
return implicitConflict;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Check for precedence conflicts (same scope, different severity)
|
|
108
|
+
const precedenceConflict = this.checkPrecedenceConflict(rule1, rule2);
|
|
109
|
+
if (precedenceConflict) {
|
|
110
|
+
return precedenceConflict;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Check for scope conflicts (overlapping but different requirements)
|
|
114
|
+
const scopeConflict = this.checkScopeConflict(rule1, rule2);
|
|
115
|
+
if (scopeConflict) {
|
|
116
|
+
return scopeConflict;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Check for direct conflicts (contradictory requirements)
|
|
124
|
+
*/
|
|
125
|
+
private checkDirectConflict(rule1: Rule, rule2: Rule): RuleConflict | null {
|
|
126
|
+
// Example: Universal allows dynamic allocation, embedded forbids it
|
|
127
|
+
if (rule1.id.includes('memory') && rule2.id.includes('memory')) {
|
|
128
|
+
const hasOverlap = rule1.category.some(cat => rule2.category.includes(cat));
|
|
129
|
+
|
|
130
|
+
if (hasOverlap) {
|
|
131
|
+
// Check if descriptions contain contradictory keywords
|
|
132
|
+
const r1Desc = rule1.description.toLowerCase();
|
|
133
|
+
const r2Desc = rule2.description.toLowerCase();
|
|
134
|
+
|
|
135
|
+
if ((r1Desc.includes('allow') && r2Desc.includes('forbid')) ||
|
|
136
|
+
(r1Desc.includes('forbid') && r2Desc.includes('allow'))) {
|
|
137
|
+
return {
|
|
138
|
+
type: 'direct',
|
|
139
|
+
severity: 'high',
|
|
140
|
+
rule1,
|
|
141
|
+
rule2,
|
|
142
|
+
description: 'Rules have contradictory requirements',
|
|
143
|
+
reason: `${rule1.name} and ${rule2.name} have opposite requirements for the same feature`,
|
|
144
|
+
suggestion: 'Apply category-specific rule precedence or use configuration override'
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Check for implicit conflicts (incompatible system states)
|
|
155
|
+
*/
|
|
156
|
+
private checkImplicitConflict(rule1: Rule, rule2: Rule): RuleConflict | null {
|
|
157
|
+
// Example: Real-time requires determinism, but another rule allows dynamic allocation
|
|
158
|
+
const r1Keywords = this.extractKeywords(rule1);
|
|
159
|
+
const r2Keywords = this.extractKeywords(rule2);
|
|
160
|
+
|
|
161
|
+
const incompatiblePairs = [
|
|
162
|
+
['deterministic', 'dynamic'],
|
|
163
|
+
['realtime', 'blocking'],
|
|
164
|
+
['embedded', 'malloc']
|
|
165
|
+
];
|
|
166
|
+
|
|
167
|
+
for (const [kw1, kw2] of incompatiblePairs) {
|
|
168
|
+
if ((r1Keywords.includes(kw1) && r2Keywords.includes(kw2)) ||
|
|
169
|
+
(r1Keywords.includes(kw2) && r2Keywords.includes(kw1))) {
|
|
170
|
+
return {
|
|
171
|
+
type: 'implicit',
|
|
172
|
+
severity: 'medium',
|
|
173
|
+
rule1,
|
|
174
|
+
rule2,
|
|
175
|
+
description: 'Rules create incompatible system states',
|
|
176
|
+
reason: `${rule1.name} requires ${kw1} but ${rule2.name} allows ${kw2}`,
|
|
177
|
+
suggestion: 'Review category-specific requirements and apply appropriate overrides'
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Check for precedence conflicts (same scope, different severity)
|
|
187
|
+
*/
|
|
188
|
+
private checkPrecedenceConflict(rule1: Rule, rule2: Rule): RuleConflict | null {
|
|
189
|
+
// Check if rules have overlapping categories
|
|
190
|
+
const overlap = rule1.category.filter(cat => rule2.category.includes(cat));
|
|
191
|
+
|
|
192
|
+
if (overlap.length > 0 && rule1.severity !== rule2.severity) {
|
|
193
|
+
// Check if they address the same topic
|
|
194
|
+
const r1Topic = this.extractTopic(rule1);
|
|
195
|
+
const r2Topic = this.extractTopic(rule2);
|
|
196
|
+
|
|
197
|
+
if (r1Topic === r2Topic) {
|
|
198
|
+
return {
|
|
199
|
+
type: 'precedence',
|
|
200
|
+
severity: 'low',
|
|
201
|
+
rule1,
|
|
202
|
+
rule2,
|
|
203
|
+
description: 'Rules have different severity for the same topic',
|
|
204
|
+
reason: `${rule1.name} (${rule1.severity}) and ${rule2.name} (${rule2.severity}) address the same topic`,
|
|
205
|
+
suggestion: 'Use highest severity or apply category-specific precedence'
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Check for scope conflicts (overlapping but different requirements)
|
|
215
|
+
*/
|
|
216
|
+
private checkScopeConflict(rule1: Rule, rule2: Rule): RuleConflict | null {
|
|
217
|
+
// Check if one rule is more specific than the other
|
|
218
|
+
const r1IsUniversal = rule1.category.includes('universal' as Category);
|
|
219
|
+
const r2IsUniversal = rule2.category.includes('universal' as Category);
|
|
220
|
+
|
|
221
|
+
if (r1IsUniversal !== r2IsUniversal) {
|
|
222
|
+
// One is universal, one is category-specific
|
|
223
|
+
const overlap = this.checkTopicOverlap(rule1, rule2);
|
|
224
|
+
|
|
225
|
+
if (overlap) {
|
|
226
|
+
return {
|
|
227
|
+
type: 'scope',
|
|
228
|
+
severity: 'low',
|
|
229
|
+
rule1,
|
|
230
|
+
rule2,
|
|
231
|
+
description: 'Universal and category-specific rules overlap',
|
|
232
|
+
reason: `${rule1.name} (universal) and ${rule2.name} (category-specific) address similar topics`,
|
|
233
|
+
suggestion: 'Category-specific rule should take precedence'
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Extract keywords from rule
|
|
243
|
+
*/
|
|
244
|
+
private extractKeywords(rule: Rule): string[] {
|
|
245
|
+
const text = `${rule.name} ${rule.description} ${rule.rationale}`.toLowerCase();
|
|
246
|
+
const keywords: string[] = [];
|
|
247
|
+
|
|
248
|
+
const patterns = [
|
|
249
|
+
'deterministic', 'dynamic', 'realtime', 'blocking', 'embedded',
|
|
250
|
+
'malloc', 'free', 'volatile', 'static', 'const', 'posix',
|
|
251
|
+
'kernel', 'driver', 'interrupt', 'dma', 'network', 'legacy'
|
|
252
|
+
];
|
|
253
|
+
|
|
254
|
+
for (const pattern of patterns) {
|
|
255
|
+
if (text.includes(pattern)) {
|
|
256
|
+
keywords.push(pattern);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return keywords;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Extract topic from rule
|
|
265
|
+
*/
|
|
266
|
+
private extractTopic(rule: Rule): string {
|
|
267
|
+
// Extract main topic from rule ID or name
|
|
268
|
+
const parts = rule.id.split('-');
|
|
269
|
+
return parts[parts.length - 1] || 'unknown';
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Check if two rules have overlapping topics
|
|
274
|
+
*/
|
|
275
|
+
private checkTopicOverlap(rule1: Rule, rule2: Rule): boolean {
|
|
276
|
+
const keywords1 = this.extractKeywords(rule1);
|
|
277
|
+
const keywords2 = this.extractKeywords(rule2);
|
|
278
|
+
|
|
279
|
+
// Check for keyword overlap
|
|
280
|
+
const overlap = keywords1.filter(kw => keywords2.includes(kw));
|
|
281
|
+
return overlap.length > 2;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Resolve a conflict based on configuration and precedence rules
|
|
286
|
+
*/
|
|
287
|
+
private resolveConflict(
|
|
288
|
+
conflict: RuleConflict,
|
|
289
|
+
config: Configuration
|
|
290
|
+
): ConflictResolution {
|
|
291
|
+
const { rule1, rule2, type } = conflict;
|
|
292
|
+
|
|
293
|
+
// Apply precedence rules
|
|
294
|
+
// 1. User Override (from configuration)
|
|
295
|
+
// 2. Category-Specific
|
|
296
|
+
// 3. Universal
|
|
297
|
+
// 4. Default
|
|
298
|
+
|
|
299
|
+
// Check if either rule is disabled in configuration
|
|
300
|
+
const r1Enabled = this.isRuleEnabledInConfig(rule1, config);
|
|
301
|
+
const r2Enabled = this.isRuleEnabledInConfig(rule2, config);
|
|
302
|
+
|
|
303
|
+
if (!r1Enabled && r2Enabled) {
|
|
304
|
+
return {
|
|
305
|
+
conflict,
|
|
306
|
+
resolution: 'use_rule2',
|
|
307
|
+
rationale: 'Rule 1 is disabled in configuration',
|
|
308
|
+
appliedRule: rule2
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (r1Enabled && !r2Enabled) {
|
|
313
|
+
return {
|
|
314
|
+
conflict,
|
|
315
|
+
resolution: 'use_rule1',
|
|
316
|
+
rationale: 'Rule 2 is disabled in configuration',
|
|
317
|
+
appliedRule: rule1
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// Category-specific wins over universal
|
|
322
|
+
const r1IsUniversal = rule1.category.includes('universal' as Category);
|
|
323
|
+
const r2IsUniversal = rule2.category.includes('universal' as Category);
|
|
324
|
+
|
|
325
|
+
if (!r1IsUniversal && r2IsUniversal) {
|
|
326
|
+
return {
|
|
327
|
+
conflict,
|
|
328
|
+
resolution: 'use_rule1',
|
|
329
|
+
rationale: 'Category-specific rule takes precedence over universal rule',
|
|
330
|
+
appliedRule: rule1
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if (r1IsUniversal && !r2IsUniversal) {
|
|
335
|
+
return {
|
|
336
|
+
conflict,
|
|
337
|
+
resolution: 'use_rule2',
|
|
338
|
+
rationale: 'Category-specific rule takes precedence over universal rule',
|
|
339
|
+
appliedRule: rule2
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// Use highest severity
|
|
344
|
+
const severityOrder = { ERROR: 3, WARNING: 2, INFO: 1 };
|
|
345
|
+
if (severityOrder[rule1.severity] > severityOrder[rule2.severity]) {
|
|
346
|
+
return {
|
|
347
|
+
conflict,
|
|
348
|
+
resolution: 'use_rule1',
|
|
349
|
+
rationale: 'Rule 1 has higher severity',
|
|
350
|
+
appliedRule: rule1
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
if (severityOrder[rule2.severity] > severityOrder[rule1.severity]) {
|
|
355
|
+
return {
|
|
356
|
+
conflict,
|
|
357
|
+
resolution: 'use_rule2',
|
|
358
|
+
rationale: 'Rule 2 has higher severity',
|
|
359
|
+
appliedRule: rule2
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// Cannot auto-resolve
|
|
364
|
+
return {
|
|
365
|
+
conflict,
|
|
366
|
+
resolution: 'user_decision',
|
|
367
|
+
rationale: 'Conflict requires manual review and decision'
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Check if rule is enabled in configuration
|
|
373
|
+
*/
|
|
374
|
+
private isRuleEnabledInConfig(rule: Rule, config: Configuration): boolean {
|
|
375
|
+
const ruleKey = rule.id.split('-').pop();
|
|
376
|
+
if (ruleKey && config.c_standards.universal_rules) {
|
|
377
|
+
const severity = config.c_standards.universal_rules[ruleKey as keyof typeof config.c_standards.universal_rules];
|
|
378
|
+
return severity !== 'disabled';
|
|
379
|
+
}
|
|
380
|
+
return true;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Generate summary statistics
|
|
385
|
+
*/
|
|
386
|
+
private generateSummary(
|
|
387
|
+
conflicts: RuleConflict[],
|
|
388
|
+
resolutions: ConflictResolution[]
|
|
389
|
+
): ConflictReport['summary'] {
|
|
390
|
+
const summary = {
|
|
391
|
+
total: conflicts.length,
|
|
392
|
+
high: 0,
|
|
393
|
+
medium: 0,
|
|
394
|
+
low: 0,
|
|
395
|
+
resolved: 0,
|
|
396
|
+
unresolved: 0
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
for (const conflict of conflicts) {
|
|
400
|
+
if (conflict.severity === 'high') summary.high++;
|
|
401
|
+
if (conflict.severity === 'medium') summary.medium++;
|
|
402
|
+
if (conflict.severity === 'low') summary.low++;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
for (const resolution of resolutions) {
|
|
406
|
+
if (resolution.resolution === 'user_decision') {
|
|
407
|
+
summary.unresolved++;
|
|
408
|
+
} else {
|
|
409
|
+
summary.resolved++;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
return summary;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Generate a formatted conflict report
|
|
418
|
+
*/
|
|
419
|
+
generateReport(report: ConflictReport): string {
|
|
420
|
+
let output = '# Rule Conflict Detection Report\n\n';
|
|
421
|
+
|
|
422
|
+
output += `## Summary\n\n`;
|
|
423
|
+
output += `- Total conflicts: ${report.summary.total}\n`;
|
|
424
|
+
output += `- High severity: ${report.summary.high}\n`;
|
|
425
|
+
output += `- Medium severity: ${report.summary.medium}\n`;
|
|
426
|
+
output += `- Low severity: ${report.summary.low}\n`;
|
|
427
|
+
output += `- Auto-resolved: ${report.summary.resolved}\n`;
|
|
428
|
+
output += `- Requires review: ${report.summary.unresolved}\n\n`;
|
|
429
|
+
|
|
430
|
+
if (report.conflicts.length === 0) {
|
|
431
|
+
output += 'No conflicts detected.\n';
|
|
432
|
+
return output;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
output += `## Conflicts\n\n`;
|
|
436
|
+
|
|
437
|
+
for (let i = 0; i < report.conflicts.length; i++) {
|
|
438
|
+
const conflict = report.conflicts[i];
|
|
439
|
+
const resolution = report.resolutions[i];
|
|
440
|
+
|
|
441
|
+
output += `### Conflict ${i + 1}: ${conflict.type.toUpperCase()} (${conflict.severity})\n\n`;
|
|
442
|
+
output += `**Description:** ${conflict.description}\n\n`;
|
|
443
|
+
output += `**Rules:**\n`;
|
|
444
|
+
output += `- ${conflict.rule1.id}: ${conflict.rule1.name}\n`;
|
|
445
|
+
output += `- ${conflict.rule2.id}: ${conflict.rule2.name}\n\n`;
|
|
446
|
+
output += `**Reason:** ${conflict.reason}\n\n`;
|
|
447
|
+
output += `**Suggestion:** ${conflict.suggestion}\n\n`;
|
|
448
|
+
output += `**Resolution:** ${resolution.resolution}\n`;
|
|
449
|
+
output += `**Rationale:** ${resolution.rationale}\n`;
|
|
450
|
+
|
|
451
|
+
if (resolution.appliedRule) {
|
|
452
|
+
output += `**Applied Rule:** ${resolution.appliedRule.id}\n`;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
output += '\n';
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
return output;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|