@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.
Files changed (307) hide show
  1. package/augment-extensions/coding-standards/c/CHANGELOG.md +55 -0
  2. package/augment-extensions/coding-standards/c/LICENSE +22 -0
  3. package/augment-extensions/coding-standards/c/README.md +167 -0
  4. package/augment-extensions/coding-standards/c/config/defaults.json +26 -0
  5. package/augment-extensions/coding-standards/c/config/examples/embedded.yaml +25 -0
  6. package/augment-extensions/coding-standards/c/config/examples/systems.json +31 -0
  7. package/augment-extensions/coding-standards/c/config/schema.json +244 -0
  8. package/augment-extensions/coding-standards/c/docs/API.md +613 -0
  9. package/augment-extensions/coding-standards/c/docs/CONFIGURATION.md +259 -0
  10. package/augment-extensions/coding-standards/c/docs/USER_GUIDE.md +567 -0
  11. package/augment-extensions/coding-standards/c/examples/drivers/Makefile +33 -0
  12. package/augment-extensions/coding-standards/c/examples/drivers/README.md +192 -0
  13. package/augment-extensions/coding-standards/c/examples/drivers/dma-example.c +224 -0
  14. package/augment-extensions/coding-standards/c/examples/drivers/example.dts +64 -0
  15. package/augment-extensions/coding-standards/c/examples/drivers/platform-driver.c +174 -0
  16. package/augment-extensions/coding-standards/c/examples/embedded/README.md +167 -0
  17. package/augment-extensions/coding-standards/c/examples/embedded/gpio-control.c +172 -0
  18. package/augment-extensions/coding-standards/c/examples/embedded/timer-isr.c +198 -0
  19. package/augment-extensions/coding-standards/c/examples/embedded/uart-communication.c +212 -0
  20. package/augment-extensions/coding-standards/c/examples/kernel/Makefile +82 -0
  21. package/augment-extensions/coding-standards/c/examples/kernel/README.md +168 -0
  22. package/augment-extensions/coding-standards/c/examples/kernel/char-device.c +198 -0
  23. package/augment-extensions/coding-standards/c/examples/kernel/proc-file.c +131 -0
  24. package/augment-extensions/coding-standards/c/examples/kernel/simple-module.c +111 -0
  25. package/augment-extensions/coding-standards/c/examples/legacy/Makefile +62 -0
  26. package/augment-extensions/coding-standards/c/examples/legacy/README.md +255 -0
  27. package/augment-extensions/coding-standards/c/examples/legacy/c89-to-c11-migration.c +268 -0
  28. package/augment-extensions/coding-standards/c/examples/legacy/compatibility-layer.c +239 -0
  29. package/augment-extensions/coding-standards/c/examples/networking/Makefile +35 -0
  30. package/augment-extensions/coding-standards/c/examples/networking/README.md +207 -0
  31. package/augment-extensions/coding-standards/c/examples/networking/protocol-parser.c +270 -0
  32. package/augment-extensions/coding-standards/c/examples/networking/tcp-server.c +197 -0
  33. package/augment-extensions/coding-standards/c/examples/networking/udp-multicast.c +220 -0
  34. package/augment-extensions/coding-standards/c/examples/realtime/Makefile +53 -0
  35. package/augment-extensions/coding-standards/c/examples/realtime/README.md +199 -0
  36. package/augment-extensions/coding-standards/c/examples/realtime/deadline-monitoring.c +260 -0
  37. package/augment-extensions/coding-standards/c/examples/realtime/priority-scheduling.c +258 -0
  38. package/augment-extensions/coding-standards/c/examples/systems/Makefile +34 -0
  39. package/augment-extensions/coding-standards/c/examples/systems/README.md +123 -0
  40. package/augment-extensions/coding-standards/c/examples/systems/ipc-pipes.c +181 -0
  41. package/augment-extensions/coding-standards/c/examples/systems/process-management.c +153 -0
  42. package/augment-extensions/coding-standards/c/examples/systems/signal-handling.c +162 -0
  43. package/augment-extensions/coding-standards/c/module.json +149 -0
  44. package/augment-extensions/coding-standards/c/rules/categories/drivers.md +635 -0
  45. package/augment-extensions/coding-standards/c/rules/categories/embedded.md +510 -0
  46. package/augment-extensions/coding-standards/c/rules/categories/kernel.md +653 -0
  47. package/augment-extensions/coding-standards/c/rules/categories/legacy.md +526 -0
  48. package/augment-extensions/coding-standards/c/rules/categories/networking.md +735 -0
  49. package/augment-extensions/coding-standards/c/rules/categories/realtime.md +631 -0
  50. package/augment-extensions/coding-standards/c/rules/categories/systems.md +586 -0
  51. package/augment-extensions/coding-standards/c/rules/universal/const-correctness.md +275 -0
  52. package/augment-extensions/coding-standards/c/rules/universal/documentation.md +251 -0
  53. package/augment-extensions/coding-standards/c/rules/universal/error-handling.md +250 -0
  54. package/augment-extensions/coding-standards/c/rules/universal/header-guards.md +254 -0
  55. package/augment-extensions/coding-standards/c/rules/universal/memory-safety.md +233 -0
  56. package/augment-extensions/coding-standards/c/rules/universal/naming.md +146 -0
  57. package/augment-extensions/coding-standards/c/src/conflict-detector.ts +461 -0
  58. package/augment-extensions/coding-standards/c/src/prompt-generator.ts +307 -0
  59. package/augment-extensions/coding-standards/c/src/rule-evaluator.ts +307 -0
  60. package/augment-extensions/coding-standards/c/src/rule-override.ts +427 -0
  61. package/augment-extensions/coding-standards/c/src/template-engine.ts +217 -0
  62. package/augment-extensions/coding-standards/c/templates/prompts/drivers.txt +191 -0
  63. package/augment-extensions/coding-standards/c/templates/prompts/embedded.txt +164 -0
  64. package/augment-extensions/coding-standards/c/templates/prompts/kernel.txt +175 -0
  65. package/augment-extensions/coding-standards/c/templates/prompts/legacy.txt +280 -0
  66. package/augment-extensions/coding-standards/c/templates/prompts/networking.txt +259 -0
  67. package/augment-extensions/coding-standards/c/templates/prompts/realtime.txt +219 -0
  68. package/augment-extensions/coding-standards/c/templates/prompts/systems.txt +147 -0
  69. package/augment-extensions/coding-standards/c/tests/integration/category-specific.test.ts +356 -0
  70. package/augment-extensions/coding-standards/c/tests/integration/end-to-end-workflow.test.ts +377 -0
  71. package/augment-extensions/coding-standards/c/tests/performance/benchmarks.test.ts +407 -0
  72. package/augment-extensions/coding-standards/c/tests/unit/config-manager.test.ts +345 -0
  73. package/augment-extensions/coding-standards/c/tests/unit/conflict-detector.test.ts +294 -0
  74. package/augment-extensions/coding-standards/c/tests/unit/prompt-generator.test.ts +174 -0
  75. package/augment-extensions/coding-standards/c/tests/unit/registry.test.ts +313 -0
  76. package/augment-extensions/coding-standards/c/tests/unit/rule-evaluator.test.ts +318 -0
  77. package/augment-extensions/coding-standards/c/tests/unit/rule-override.test.ts +326 -0
  78. package/augment-extensions/coding-standards/c/tests/unit/template-engine.test.ts +314 -0
  79. package/augment-extensions/coding-standards/go/CHARACTER-COUNT-REPORT.md +135 -0
  80. package/augment-extensions/coding-standards/go/PHASE1-COMPLETION.md +146 -0
  81. package/augment-extensions/coding-standards/go/PHASE4-COMPLETION.md +184 -0
  82. package/augment-extensions/coding-standards/go/README.md +200 -0
  83. package/augment-extensions/coding-standards/go/VALIDATION-CHECKLIST.md +154 -0
  84. package/augment-extensions/coding-standards/go/config/examples/example-cli.json +15 -0
  85. package/augment-extensions/coding-standards/go/config/examples/example-microservices.json +21 -0
  86. package/augment-extensions/coding-standards/go/config/examples/example-multi-category.yaml +24 -0
  87. package/augment-extensions/coding-standards/go/config/examples/example-web.json +15 -0
  88. package/augment-extensions/coding-standards/go/config/schema.json +110 -0
  89. package/augment-extensions/coding-standards/go/docs/CATEGORIES.md +221 -0
  90. package/augment-extensions/coding-standards/go/docs/CONFIGURATION.md +198 -0
  91. package/augment-extensions/coding-standards/go/docs/TROUBLESHOOTING.md +285 -0
  92. package/augment-extensions/coding-standards/go/examples/cli/cobra-app.go +287 -0
  93. package/augment-extensions/coding-standards/go/examples/cloud-native-app.go +217 -0
  94. package/augment-extensions/coding-standards/go/examples/devops-tool.go +250 -0
  95. package/augment-extensions/coding-standards/go/examples/distributed-system.go +247 -0
  96. package/augment-extensions/coding-standards/go/examples/microservices/grpc-service.go +253 -0
  97. package/augment-extensions/coding-standards/go/examples/rest-api.go +270 -0
  98. package/augment-extensions/coding-standards/go/examples/web/http-server.go +224 -0
  99. package/augment-extensions/coding-standards/go/module.json +139 -0
  100. package/augment-extensions/coding-standards/go/rules/categories/api-development/api-versioning.md +149 -0
  101. package/augment-extensions/coding-standards/go/rules/categories/api-development/rate-limiting.md +209 -0
  102. package/augment-extensions/coding-standards/go/rules/categories/api-development/rest-api-design.md +183 -0
  103. package/augment-extensions/coding-standards/go/rules/categories/cloud-native/cloud-config.md +193 -0
  104. package/augment-extensions/coding-standards/go/rules/categories/cloud-native/health-checks.md +231 -0
  105. package/augment-extensions/coding-standards/go/rules/categories/cloud-native/kubernetes.md +180 -0
  106. package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/automation.md +179 -0
  107. package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/ci-cd-integration.md +147 -0
  108. package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/infrastructure-as-code.md +231 -0
  109. package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/caching.md +150 -0
  110. package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/consensus.md +187 -0
  111. package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/event-sourcing.md +246 -0
  112. package/augment-extensions/coding-standards/go/rules/cli/command-parsing.md +264 -0
  113. package/augment-extensions/coding-standards/go/rules/cli/configuration.md +268 -0
  114. package/augment-extensions/coding-standards/go/rules/cli/cross-platform.md +324 -0
  115. package/augment-extensions/coding-standards/go/rules/microservices/distributed-tracing.md +253 -0
  116. package/augment-extensions/coding-standards/go/rules/microservices/grpc.md +257 -0
  117. package/augment-extensions/coding-standards/go/rules/microservices/metrics.md +278 -0
  118. package/augment-extensions/coding-standards/go/rules/microservices/service-discovery.md +249 -0
  119. package/augment-extensions/coding-standards/go/rules/universal/code-organization.md +221 -0
  120. package/augment-extensions/coding-standards/go/rules/universal/documentation.md +269 -0
  121. package/augment-extensions/coding-standards/go/rules/universal/performance.md +323 -0
  122. package/augment-extensions/coding-standards/go/rules/universal/testing.md +162 -0
  123. package/augment-extensions/coding-standards/go/rules/web/graceful-shutdown.md +249 -0
  124. package/augment-extensions/coding-standards/go/rules/web/http-handlers.md +164 -0
  125. package/augment-extensions/coding-standards/go/rules/web/middleware.md +234 -0
  126. package/augment-extensions/coding-standards/go/rules/web/routing.md +251 -0
  127. package/augment-extensions/coding-standards/go/templates/prompts/api.md +160 -0
  128. package/augment-extensions/coding-standards/go/templates/prompts/cli.md +225 -0
  129. package/augment-extensions/coding-standards/go/templates/prompts/cloud-native.md +121 -0
  130. package/augment-extensions/coding-standards/go/templates/prompts/devops.md +146 -0
  131. package/augment-extensions/coding-standards/go/templates/prompts/distributed.md +133 -0
  132. package/augment-extensions/coding-standards/go/templates/prompts/microservices.md +225 -0
  133. package/augment-extensions/coding-standards/go/templates/prompts/web.md +181 -0
  134. package/augment-extensions/coding-standards/go/tests/integration/module-integration.test.ts +164 -0
  135. package/augment-extensions/coding-standards/go/tests/unit/category-selection.test.ts +147 -0
  136. package/augment-extensions/coding-standards/go/tests/unit/module-structure.test.ts +154 -0
  137. package/augment-extensions/coding-standards/go/tests/validate-character-count.ps1 +13 -0
  138. package/augment-extensions/coding-standards/go/tests/validate-examples.ps1 +148 -0
  139. package/augment-extensions/coding-standards/go/tests/validate-examples.sh +135 -0
  140. package/cli/dist/analysis/ast-parser.d.ts +47 -0
  141. package/cli/dist/analysis/ast-parser.d.ts.map +1 -0
  142. package/cli/dist/analysis/ast-parser.js +161 -0
  143. package/cli/dist/analysis/ast-parser.js.map +1 -0
  144. package/cli/dist/analysis/complexity-analyzer.d.ts +27 -0
  145. package/cli/dist/analysis/complexity-analyzer.d.ts.map +1 -0
  146. package/cli/dist/analysis/complexity-analyzer.js +189 -0
  147. package/cli/dist/analysis/complexity-analyzer.js.map +1 -0
  148. package/cli/dist/analysis/dependency-analyzer.d.ts +23 -0
  149. package/cli/dist/analysis/dependency-analyzer.d.ts.map +1 -0
  150. package/cli/dist/analysis/dependency-analyzer.js +237 -0
  151. package/cli/dist/analysis/dependency-analyzer.js.map +1 -0
  152. package/cli/dist/analysis/index.d.ts +9 -0
  153. package/cli/dist/analysis/index.d.ts.map +1 -0
  154. package/cli/dist/analysis/index.js +25 -0
  155. package/cli/dist/analysis/index.js.map +1 -0
  156. package/cli/dist/analysis/security-scanner.d.ts +11 -0
  157. package/cli/dist/analysis/security-scanner.d.ts.map +1 -0
  158. package/cli/dist/analysis/security-scanner.js +294 -0
  159. package/cli/dist/analysis/security-scanner.js.map +1 -0
  160. package/cli/dist/analysis/types.d.ts +151 -0
  161. package/cli/dist/analysis/types.d.ts.map +1 -0
  162. package/cli/dist/analysis/types.js +6 -0
  163. package/cli/dist/analysis/types.js.map +1 -0
  164. package/cli/dist/cli.js +24 -0
  165. package/cli/dist/cli.js.map +1 -1
  166. package/cli/dist/commands/code-analysis.d.ts +11 -0
  167. package/cli/dist/commands/code-analysis.d.ts.map +1 -0
  168. package/cli/dist/commands/code-analysis.js +412 -0
  169. package/cli/dist/commands/code-analysis.js.map +1 -0
  170. package/modules.md +99 -3
  171. package/package.json +14 -2
  172. package/cli/dist/commands/agent.d.ts +0 -37
  173. package/cli/dist/commands/agent.d.ts.map +0 -1
  174. package/cli/dist/commands/agent.js +0 -222
  175. package/cli/dist/commands/agent.js.map +0 -1
  176. package/cli/dist/commands/beads.d.ts +0 -64
  177. package/cli/dist/commands/beads.d.ts.map +0 -1
  178. package/cli/dist/commands/beads.js +0 -377
  179. package/cli/dist/commands/beads.js.map +0 -1
  180. package/cli/dist/commands/change.d.ts +0 -54
  181. package/cli/dist/commands/change.d.ts.map +0 -1
  182. package/cli/dist/commands/change.js +0 -243
  183. package/cli/dist/commands/change.js.map +0 -1
  184. package/cli/dist/commands/clean.d.ts +0 -15
  185. package/cli/dist/commands/clean.d.ts.map +0 -1
  186. package/cli/dist/commands/clean.js +0 -63
  187. package/cli/dist/commands/clean.js.map +0 -1
  188. package/cli/dist/commands/clone.d.ts +0 -15
  189. package/cli/dist/commands/clone.d.ts.map +0 -1
  190. package/cli/dist/commands/clone.js +0 -49
  191. package/cli/dist/commands/clone.js.map +0 -1
  192. package/cli/dist/commands/config.d.ts +0 -33
  193. package/cli/dist/commands/config.d.ts.map +0 -1
  194. package/cli/dist/commands/config.js +0 -166
  195. package/cli/dist/commands/config.js.map +0 -1
  196. package/cli/dist/commands/context.d.ts +0 -38
  197. package/cli/dist/commands/context.d.ts.map +0 -1
  198. package/cli/dist/commands/context.js +0 -205
  199. package/cli/dist/commands/context.js.map +0 -1
  200. package/cli/dist/commands/create.d.ts +0 -18
  201. package/cli/dist/commands/create.d.ts.map +0 -1
  202. package/cli/dist/commands/create.js +0 -178
  203. package/cli/dist/commands/create.js.map +0 -1
  204. package/cli/dist/commands/diff.d.ts +0 -19
  205. package/cli/dist/commands/diff.d.ts.map +0 -1
  206. package/cli/dist/commands/diff.js +0 -104
  207. package/cli/dist/commands/diff.js.map +0 -1
  208. package/cli/dist/commands/doctor.d.ts +0 -14
  209. package/cli/dist/commands/doctor.d.ts.map +0 -1
  210. package/cli/dist/commands/doctor.js +0 -62
  211. package/cli/dist/commands/doctor.js.map +0 -1
  212. package/cli/dist/commands/export.d.ts +0 -28
  213. package/cli/dist/commands/export.d.ts.map +0 -1
  214. package/cli/dist/commands/export.js +0 -135
  215. package/cli/dist/commands/export.js.map +0 -1
  216. package/cli/dist/commands/import.d.ts +0 -23
  217. package/cli/dist/commands/import.d.ts.map +0 -1
  218. package/cli/dist/commands/import.js +0 -118
  219. package/cli/dist/commands/import.js.map +0 -1
  220. package/cli/dist/commands/prompt.d.ts +0 -45
  221. package/cli/dist/commands/prompt.d.ts.map +0 -1
  222. package/cli/dist/commands/prompt.js +0 -223
  223. package/cli/dist/commands/prompt.js.map +0 -1
  224. package/cli/dist/commands/spec.d.ts +0 -57
  225. package/cli/dist/commands/spec.d.ts.map +0 -1
  226. package/cli/dist/commands/spec.js +0 -279
  227. package/cli/dist/commands/spec.js.map +0 -1
  228. package/cli/dist/commands/stats.d.ts +0 -18
  229. package/cli/dist/commands/stats.d.ts.map +0 -1
  230. package/cli/dist/commands/stats.js +0 -85
  231. package/cli/dist/commands/stats.js.map +0 -1
  232. package/cli/dist/commands/task.d.ts +0 -65
  233. package/cli/dist/commands/task.d.ts.map +0 -1
  234. package/cli/dist/commands/task.js +0 -282
  235. package/cli/dist/commands/task.js.map +0 -1
  236. package/cli/dist/commands/template.d.ts +0 -17
  237. package/cli/dist/commands/template.d.ts.map +0 -1
  238. package/cli/dist/commands/template.js +0 -55
  239. package/cli/dist/commands/template.js.map +0 -1
  240. package/cli/dist/utils/agent-config.d.ts +0 -129
  241. package/cli/dist/utils/agent-config.d.ts.map +0 -1
  242. package/cli/dist/utils/agent-config.js +0 -297
  243. package/cli/dist/utils/agent-config.js.map +0 -1
  244. package/cli/dist/utils/beads-graph.d.ts +0 -17
  245. package/cli/dist/utils/beads-graph.d.ts.map +0 -1
  246. package/cli/dist/utils/beads-graph.js +0 -150
  247. package/cli/dist/utils/beads-graph.js.map +0 -1
  248. package/cli/dist/utils/beads-integration.d.ts +0 -112
  249. package/cli/dist/utils/beads-integration.d.ts.map +0 -1
  250. package/cli/dist/utils/beads-integration.js +0 -312
  251. package/cli/dist/utils/beads-integration.js.map +0 -1
  252. package/cli/dist/utils/beads-reporter.d.ts +0 -17
  253. package/cli/dist/utils/beads-reporter.d.ts.map +0 -1
  254. package/cli/dist/utils/beads-reporter.js +0 -160
  255. package/cli/dist/utils/beads-reporter.js.map +0 -1
  256. package/cli/dist/utils/cache-manager.d.ts +0 -55
  257. package/cli/dist/utils/cache-manager.d.ts.map +0 -1
  258. package/cli/dist/utils/cache-manager.js +0 -150
  259. package/cli/dist/utils/cache-manager.js.map +0 -1
  260. package/cli/dist/utils/change-manager.d.ts +0 -70
  261. package/cli/dist/utils/change-manager.d.ts.map +0 -1
  262. package/cli/dist/utils/change-manager.js +0 -412
  263. package/cli/dist/utils/change-manager.js.map +0 -1
  264. package/cli/dist/utils/config-manager-enhanced.d.ts +0 -66
  265. package/cli/dist/utils/config-manager-enhanced.d.ts.map +0 -1
  266. package/cli/dist/utils/config-manager-enhanced.js +0 -77
  267. package/cli/dist/utils/config-manager-enhanced.js.map +0 -1
  268. package/cli/dist/utils/context-manager.d.ts +0 -96
  269. package/cli/dist/utils/context-manager.d.ts.map +0 -1
  270. package/cli/dist/utils/context-manager.js +0 -258
  271. package/cli/dist/utils/context-manager.js.map +0 -1
  272. package/cli/dist/utils/diff-engine.d.ts +0 -78
  273. package/cli/dist/utils/diff-engine.d.ts.map +0 -1
  274. package/cli/dist/utils/diff-engine.js +0 -233
  275. package/cli/dist/utils/diff-engine.js.map +0 -1
  276. package/cli/dist/utils/export-system.d.ts +0 -101
  277. package/cli/dist/utils/export-system.d.ts.map +0 -1
  278. package/cli/dist/utils/export-system.js +0 -289
  279. package/cli/dist/utils/export-system.js.map +0 -1
  280. package/cli/dist/utils/health-checker.d.ts +0 -66
  281. package/cli/dist/utils/health-checker.d.ts.map +0 -1
  282. package/cli/dist/utils/health-checker.js +0 -285
  283. package/cli/dist/utils/health-checker.js.map +0 -1
  284. package/cli/dist/utils/import-system.d.ts +0 -74
  285. package/cli/dist/utils/import-system.d.ts.map +0 -1
  286. package/cli/dist/utils/import-system.js +0 -317
  287. package/cli/dist/utils/import-system.js.map +0 -1
  288. package/cli/dist/utils/module-cloner.d.ts +0 -40
  289. package/cli/dist/utils/module-cloner.d.ts.map +0 -1
  290. package/cli/dist/utils/module-cloner.js +0 -136
  291. package/cli/dist/utils/module-cloner.js.map +0 -1
  292. package/cli/dist/utils/prompt-manager.d.ts +0 -90
  293. package/cli/dist/utils/prompt-manager.d.ts.map +0 -1
  294. package/cli/dist/utils/prompt-manager.js +0 -302
  295. package/cli/dist/utils/prompt-manager.js.map +0 -1
  296. package/cli/dist/utils/spec-manager.d.ts +0 -65
  297. package/cli/dist/utils/spec-manager.d.ts.map +0 -1
  298. package/cli/dist/utils/spec-manager.js +0 -329
  299. package/cli/dist/utils/spec-manager.js.map +0 -1
  300. package/cli/dist/utils/stats-collector.d.ts +0 -74
  301. package/cli/dist/utils/stats-collector.d.ts.map +0 -1
  302. package/cli/dist/utils/stats-collector.js +0 -164
  303. package/cli/dist/utils/stats-collector.js.map +0 -1
  304. package/cli/dist/utils/template-engine.d.ts +0 -47
  305. package/cli/dist/utils/template-engine.d.ts.map +0 -1
  306. package/cli/dist/utils/template-engine.js +0 -204
  307. package/cli/dist/utils/template-engine.js.map +0 -1
@@ -0,0 +1,631 @@
1
+ # Rule: Real-Time Systems
2
+
3
+ ## Metadata
4
+ - **ID**: category-realtime
5
+ - **Category**: realtime
6
+ - **Severity**: ERROR
7
+ - **Standard**: POSIX Real-Time Extensions, RTOS Best Practices
8
+ - **Version**: 1.0.0
9
+
10
+ ## Description
11
+ Real-time systems programming rules covering deterministic timing, priority-based scheduling, deadline management, and avoiding priority inversion.
12
+
13
+ ## Rationale
14
+ Real-time systems must respond to events within strict time constraints. Missing deadlines can lead to system failure, data loss, or safety hazards. These rules ensure predictable, deterministic behavior.
15
+
16
+ ## Applies To
17
+ - C Standards: c99, c11, c17
18
+ - Categories: realtime
19
+ - Platforms: RTOS (FreeRTOS, Zephyr, VxWorks), POSIX real-time, embedded systems
20
+
21
+ ## Rule Details
22
+
23
+ ### 1. Deterministic Timing
24
+ - Avoid unbounded loops
25
+ - Use fixed-size data structures
26
+ - Avoid dynamic memory allocation
27
+ - Minimize interrupt latency
28
+ - Use worst-case execution time (WCET) analysis
29
+
30
+ ### 2. Priority-Based Scheduling
31
+ - Assign priorities based on deadline
32
+ - Use rate-monotonic or deadline-monotonic scheduling
33
+ - Higher priority for shorter deadlines
34
+ - Document priority assignments
35
+
36
+ ### 3. Avoiding Priority Inversion
37
+ - Use priority inheritance mutexes
38
+ - Minimize critical section duration
39
+ - Avoid nested locks when possible
40
+ - Use priority ceiling protocol
41
+
42
+ ### 4. Deadline Management
43
+ - Track task execution time
44
+ - Monitor deadline misses
45
+ - Implement deadline handlers
46
+ - Use watchdog timers
47
+
48
+ ### 5. Interrupt Management
49
+ - Keep ISRs short and deterministic
50
+ - Defer processing to tasks
51
+ - Use interrupt priorities correctly
52
+ - Disable interrupts minimally
53
+
54
+ ## Examples
55
+
56
+ ### ✅ Example 1: Priority-Based Task Creation (FreeRTOS)
57
+
58
+ ```c
59
+ #include "FreeRTOS.h"
60
+ #include "task.h"
61
+
62
+ #define TASK_STACK_SIZE 256
63
+
64
+ // Priority assignments (higher number = higher priority)
65
+ #define PRIORITY_CRITICAL 5 // 1ms deadline
66
+ #define PRIORITY_HIGH 4 // 10ms deadline
67
+ #define PRIORITY_MEDIUM 3 // 100ms deadline
68
+ #define PRIORITY_LOW 2 // 1s deadline
69
+ #define PRIORITY_IDLE 1 // Background
70
+
71
+ void critical_task(void *pvParameters) {
72
+ TickType_t xLastWakeTime = xTaskGetTickCount();
73
+ const TickType_t xPeriod = pdMS_TO_TICKS(1); // 1ms period
74
+
75
+ while (1) {
76
+ // Critical processing (must complete in <1ms)
77
+ process_critical_data();
78
+
79
+ // Wait for next period
80
+ vTaskDelayUntil(&xLastWakeTime, xPeriod);
81
+ }
82
+ }
83
+
84
+ void create_realtime_tasks(void) {
85
+ BaseType_t ret;
86
+
87
+ ret = xTaskCreate(critical_task, "Critical", TASK_STACK_SIZE,
88
+ NULL, PRIORITY_CRITICAL, NULL);
89
+ if (ret != pdPASS) {
90
+ // Handle error
91
+ error_handler();
92
+ }
93
+
94
+ ret = xTaskCreate(high_priority_task, "High", TASK_STACK_SIZE,
95
+ NULL, PRIORITY_HIGH, NULL);
96
+ if (ret != pdPASS) {
97
+ error_handler();
98
+ }
99
+ }
100
+ ```
101
+
102
+ ### ❌ Example 1: Poor Priority Assignment
103
+
104
+ ```c
105
+ // WRONG: All tasks at same priority - no real-time guarantees
106
+ xTaskCreate(critical_task, "Critical", 256, NULL, 1, NULL);
107
+ xTaskCreate(background_task, "Background", 256, NULL, 1, NULL);
108
+ // Both tasks will round-robin - critical task may miss deadlines!
109
+ ```
110
+
111
+ ### ✅ Example 2: Priority Inheritance Mutex
112
+
113
+ ```c
114
+ #include "FreeRTOS.h"
115
+ #include "semphr.h"
116
+
117
+ static SemaphoreHandle_t xMutex;
118
+
119
+ void init_priority_inheritance_mutex(void) {
120
+ // Create mutex with priority inheritance
121
+ xMutex = xSemaphoreCreateMutex();
122
+ if (xMutex == NULL) {
123
+ error_handler();
124
+ }
125
+ }
126
+
127
+ void high_priority_task(void *pvParameters) {
128
+ while (1) {
129
+ // Take mutex (will inherit priority if needed)
130
+ if (xSemaphoreTake(xMutex, portMAX_DELAY) == pdTRUE) {
131
+ // Critical section
132
+ access_shared_resource();
133
+
134
+ // Release mutex
135
+ xSemaphoreGive(xMutex);
136
+ }
137
+
138
+ vTaskDelay(pdMS_TO_TICKS(10));
139
+ }
140
+ }
141
+
142
+ void low_priority_task(void *pvParameters) {
143
+ while (1) {
144
+ if (xSemaphoreTake(xMutex, portMAX_DELAY) == pdTRUE) {
145
+ // If high-priority task waits, this task inherits its priority
146
+ access_shared_resource();
147
+ xSemaphoreGive(xMutex);
148
+ }
149
+
150
+ vTaskDelay(pdMS_TO_TICKS(100));
151
+ }
152
+ }
153
+ ```
154
+
155
+ ### ❌ Example 2: Priority Inversion Risk
156
+
157
+ ```c
158
+ // WRONG: Using binary semaphore instead of mutex
159
+ SemaphoreHandle_t xSemaphore = xSemaphoreCreateBinary();
160
+
161
+ // No priority inheritance - can cause priority inversion!
162
+ // High-priority task blocked by low-priority task
163
+ // Medium-priority task preempts low-priority task
164
+ // High-priority task waits indefinitely!
165
+ ```
166
+
167
+ ### ✅ Example 3: Deterministic Loop with Bounded Iterations
168
+
169
+ ```c
170
+ #include <stdint.h>
171
+
172
+ #define MAX_ITEMS 100
173
+
174
+ typedef struct {
175
+ uint32_t data[MAX_ITEMS];
176
+ uint32_t count;
177
+ } DataBuffer;
178
+
179
+ // Deterministic: always processes exactly MAX_ITEMS
180
+ uint32_t process_buffer_deterministic(DataBuffer *buf) {
181
+ uint32_t sum = 0;
182
+ uint32_t i;
183
+
184
+ // Fixed iteration count - deterministic WCET
185
+ for (i = 0; i < MAX_ITEMS; i++) {
186
+ if (i < buf->count) {
187
+ sum += buf->data[i];
188
+ }
189
+ }
190
+
191
+ return sum;
192
+ }
193
+ ```
194
+
195
+ ### ❌ Example 3: Non-Deterministic Loop
196
+
197
+ ```c
198
+ // WRONG: Unbounded loop - non-deterministic execution time
199
+ uint32_t bad_process_buffer(DataBuffer *buf) {
200
+ uint32_t sum = 0;
201
+ uint32_t i = 0;
202
+
203
+ // Variable iteration count - unpredictable WCET!
204
+ while (i < buf->count) { // count could be anything!
205
+ sum += buf->data[i];
206
+ i++;
207
+ }
208
+
209
+ return sum;
210
+ }
211
+ ```
212
+
213
+ ### ✅ Example 4: Deadline Monitoring
214
+
215
+ ```c
216
+ #include "FreeRTOS.h"
217
+ #include "task.h"
218
+
219
+ typedef struct {
220
+ TickType_t period;
221
+ TickType_t deadline;
222
+ TickType_t wcet; // Worst-case execution time
223
+ uint32_t missed_deadlines;
224
+ } TaskTiming;
225
+
226
+ static TaskTiming task_timing = {
227
+ .period = pdMS_TO_TICKS(10),
228
+ .deadline = pdMS_TO_TICKS(10),
229
+ .wcet = pdMS_TO_TICKS(5),
230
+ .missed_deadlines = 0
231
+ };
232
+
233
+ void monitored_task(void *pvParameters) {
234
+ TickType_t xLastWakeTime = xTaskGetTickCount();
235
+ TickType_t xStartTime, xEndTime, xExecutionTime;
236
+
237
+ while (1) {
238
+ xStartTime = xTaskGetTickCount();
239
+
240
+ // Perform task work
241
+ do_task_work();
242
+
243
+ xEndTime = xTaskGetTickCount();
244
+ xExecutionTime = xEndTime - xStartTime;
245
+
246
+ // Check for deadline miss
247
+ if (xExecutionTime > task_timing.deadline) {
248
+ task_timing.missed_deadlines++;
249
+ handle_deadline_miss();
250
+ }
251
+
252
+ // Update WCET if needed
253
+ if (xExecutionTime > task_timing.wcet) {
254
+ task_timing.wcet = xExecutionTime;
255
+ }
256
+
257
+ vTaskDelayUntil(&xLastWakeTime, task_timing.period);
258
+ }
259
+ }
260
+ ```
261
+
262
+ ### ✅ Example 5: Short ISR with Deferred Processing
263
+
264
+ ```c
265
+ #include "FreeRTOS.h"
266
+ #include "semphr.h"
267
+
268
+ static SemaphoreHandle_t xDataReadySemaphore;
269
+ static volatile uint32_t received_data;
270
+
271
+ // ISR: Keep it minimal and deterministic
272
+ void UART_IRQHandler(void) {
273
+ BaseType_t xHigherPriorityTaskWoken = pdFALSE;
274
+
275
+ // Read data (clears interrupt)
276
+ received_data = UART->DR;
277
+
278
+ // Signal task to process data
279
+ xSemaphoreGiveFromISR(xDataReadySemaphore, &xHigherPriorityTaskWoken);
280
+
281
+ // Yield if higher priority task was woken
282
+ portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
283
+ }
284
+
285
+ // Task: Process data outside ISR
286
+ void data_processing_task(void *pvParameters) {
287
+ while (1) {
288
+ // Wait for data from ISR
289
+ if (xSemaphoreTake(xDataReadySemaphore, portMAX_DELAY) == pdTRUE) {
290
+ // Process data (can take longer, use resources)
291
+ process_received_data(received_data);
292
+ }
293
+ }
294
+ }
295
+ ```
296
+
297
+ ### ✅ Example 6: Rate Monotonic Scheduling
298
+
299
+ ```c
300
+ // Rate Monotonic Scheduling: Shorter period = Higher priority
301
+
302
+ // Task 1: Period = 10ms, Priority = 5 (highest)
303
+ void task_10ms(void *pvParameters) {
304
+ TickType_t xLastWakeTime = xTaskGetTickCount();
305
+ const TickType_t xPeriod = pdMS_TO_TICKS(10);
306
+
307
+ while (1) {
308
+ // Execute in <10ms
309
+ fast_control_loop();
310
+ vTaskDelayUntil(&xLastWakeTime, xPeriod);
311
+ }
312
+ }
313
+
314
+ // Task 2: Period = 50ms, Priority = 4
315
+ void task_50ms(void *pvParameters) {
316
+ TickType_t xLastWakeTime = xTaskGetTickCount();
317
+ const TickType_t xPeriod = pdMS_TO_TICKS(50);
318
+
319
+ while (1) {
320
+ // Execute in <50ms
321
+ medium_speed_processing();
322
+ vTaskDelayUntil(&xLastWakeTime, xPeriod);
323
+ }
324
+ }
325
+
326
+ // Task 3: Period = 100ms, Priority = 3
327
+ void task_100ms(void *pvParameters) {
328
+ TickType_t xLastWakeTime = xTaskGetTickCount();
329
+ const TickType_t xPeriod = pdMS_TO_TICKS(100);
330
+
331
+ while (1) {
332
+ // Execute in <100ms
333
+ slow_background_work();
334
+ vTaskDelayUntil(&xLastWakeTime, xPeriod);
335
+ }
336
+ }
337
+
338
+ // Schedulability test: U = C1/T1 + C2/T2 + C3/T3 <= n(2^(1/n) - 1)
339
+ // For 3 tasks: U <= 0.78
340
+ ```
341
+
342
+ ### ✅ Example 7: Minimal Critical Section
343
+
344
+ ```c
345
+ #include "FreeRTOS.h"
346
+ #include "task.h"
347
+
348
+ static volatile uint32_t shared_counter = 0;
349
+
350
+ // Good: Minimal critical section
351
+ void increment_counter_good(void) {
352
+ taskENTER_CRITICAL();
353
+ shared_counter++; // Very short operation
354
+ taskEXIT_CRITICAL();
355
+ }
356
+
357
+ // Better: Use atomic operations if available
358
+ void increment_counter_atomic(void) {
359
+ __atomic_fetch_add(&shared_counter, 1, __ATOMIC_SEQ_CST);
360
+ }
361
+ ```
362
+
363
+ ### ❌ Example 7: Long Critical Section
364
+
365
+ ```c
366
+ // WRONG: Long critical section blocks all interrupts
367
+ void bad_critical_section(void) {
368
+ taskENTER_CRITICAL();
369
+
370
+ // WRONG: Complex processing with interrupts disabled!
371
+ for (int i = 0; i < 1000; i++) {
372
+ complex_calculation();
373
+ }
374
+
375
+ shared_counter++;
376
+ taskEXIT_CRITICAL();
377
+ // Interrupts were disabled for too long!
378
+ }
379
+ ```
380
+
381
+ ### ✅ Example 8: POSIX Real-Time Scheduling
382
+
383
+ ```c
384
+ #include <pthread.h>
385
+ #include <sched.h>
386
+ #include <time.h>
387
+
388
+ void* realtime_thread(void* arg) {
389
+ struct timespec next_period;
390
+ const long period_ns = 10000000; // 10ms
391
+
392
+ clock_gettime(CLOCK_MONOTONIC, &next_period);
393
+
394
+ while (1) {
395
+ // Do work
396
+ perform_realtime_task();
397
+
398
+ // Calculate next period
399
+ next_period.tv_nsec += period_ns;
400
+ if (next_period.tv_nsec >= 1000000000) {
401
+ next_period.tv_nsec -= 1000000000;
402
+ next_period.tv_sec++;
403
+ }
404
+
405
+ // Sleep until next period
406
+ clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &next_period, NULL);
407
+ }
408
+
409
+ return NULL;
410
+ }
411
+
412
+ int create_realtime_thread(void) {
413
+ pthread_t thread;
414
+ pthread_attr_t attr;
415
+ struct sched_param param;
416
+ int ret;
417
+
418
+ // Initialize thread attributes
419
+ pthread_attr_init(&attr);
420
+
421
+ // Set scheduling policy to FIFO
422
+ pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
423
+
424
+ // Set priority (1-99, higher is more important)
425
+ param.sched_priority = 80;
426
+ pthread_attr_setschedparam(&attr, &param);
427
+
428
+ // Set inherit scheduler to explicit
429
+ pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
430
+
431
+ // Create thread
432
+ ret = pthread_create(&thread, &attr, realtime_thread, NULL);
433
+
434
+ pthread_attr_destroy(&attr);
435
+
436
+ return ret;
437
+ }
438
+ ```
439
+
440
+ ### ✅ Example 9: Jitter Reduction
441
+
442
+ ```c
443
+ #include "FreeRTOS.h"
444
+ #include "task.h"
445
+
446
+ // Reduce jitter by using absolute timing
447
+ void low_jitter_task(void *pvParameters) {
448
+ TickType_t xLastWakeTime;
449
+ const TickType_t xPeriod = pdMS_TO_TICKS(10);
450
+
451
+ // Initialize with current time
452
+ xLastWakeTime = xTaskGetTickCount();
453
+
454
+ while (1) {
455
+ // vTaskDelayUntil provides lower jitter than vTaskDelay
456
+ // because it uses absolute time, not relative delay
457
+ vTaskDelayUntil(&xLastWakeTime, xPeriod);
458
+
459
+ // Task executes at precise intervals
460
+ precise_timing_required_function();
461
+ }
462
+ }
463
+ ```
464
+
465
+ ### ❌ Example 9: High Jitter
466
+
467
+ ```c
468
+ // WRONG: Using relative delay accumulates jitter
469
+ void high_jitter_task(void *pvParameters) {
470
+ while (1) {
471
+ precise_timing_required_function();
472
+
473
+ // WRONG: Delay is relative to when task finishes
474
+ // Jitter accumulates over time!
475
+ vTaskDelay(pdMS_TO_TICKS(10));
476
+ }
477
+ }
478
+ ```
479
+
480
+ ### ✅ Example 10: Stack Usage Monitoring
481
+
482
+ ```c
483
+ #include "FreeRTOS.h"
484
+ #include "task.h"
485
+
486
+ void monitor_stack_usage(void) {
487
+ TaskHandle_t xHandle = xTaskGetCurrentTaskHandle();
488
+ UBaseType_t uxHighWaterMark;
489
+
490
+ // Get minimum free stack space (in words)
491
+ uxHighWaterMark = uxTaskGetStackHighWaterMark(xHandle);
492
+
493
+ if (uxHighWaterMark < 50) { // Less than 50 words free
494
+ // Stack overflow risk!
495
+ handle_low_stack_warning();
496
+ }
497
+ }
498
+
499
+ void realtime_task_with_monitoring(void *pvParameters) {
500
+ while (1) {
501
+ do_work();
502
+
503
+ // Periodically check stack usage
504
+ monitor_stack_usage();
505
+
506
+ vTaskDelay(pdMS_TO_TICKS(100));
507
+ }
508
+ }
509
+ ```
510
+
511
+ ### ✅ Example 11: Watchdog Timer for Deadline Enforcement
512
+
513
+ ```c
514
+ #include "FreeRTOS.h"
515
+ #include "timers.h"
516
+
517
+ static TimerHandle_t xWatchdogTimer;
518
+
519
+ void watchdog_callback(TimerHandle_t xTimer) {
520
+ // Deadline missed - task didn't reset watchdog in time
521
+ handle_deadline_violation();
522
+
523
+ // Could reset system, log error, switch to safe mode, etc.
524
+ }
525
+
526
+ void init_task_watchdog(void) {
527
+ // Create one-shot timer (10ms timeout)
528
+ xWatchdogTimer = xTimerCreate("Watchdog", pdMS_TO_TICKS(10),
529
+ pdFALSE, NULL, watchdog_callback);
530
+ }
531
+
532
+ void deadline_critical_task(void *pvParameters) {
533
+ while (1) {
534
+ // Start watchdog
535
+ xTimerStart(xWatchdogTimer, 0);
536
+
537
+ // Perform time-critical work
538
+ time_critical_function();
539
+
540
+ // Reset watchdog (deadline met)
541
+ xTimerReset(xWatchdogTimer, 0);
542
+
543
+ vTaskDelay(pdMS_TO_TICKS(10));
544
+ }
545
+ }
546
+ ```
547
+
548
+ ### ✅ Example 12: Memory Pool for Deterministic Allocation
549
+
550
+ ```c
551
+ #include <stdint.h>
552
+ #include <string.h>
553
+
554
+ #define POOL_SIZE 10
555
+ #define BLOCK_SIZE 256
556
+
557
+ typedef struct {
558
+ uint8_t data[BLOCK_SIZE];
559
+ bool in_use;
560
+ } MemoryBlock;
561
+
562
+ static MemoryBlock memory_pool[POOL_SIZE];
563
+
564
+ // Deterministic allocation (O(n) worst case, bounded)
565
+ void* pool_alloc(void) {
566
+ for (int i = 0; i < POOL_SIZE; i++) {
567
+ if (!memory_pool[i].in_use) {
568
+ memory_pool[i].in_use = true;
569
+ memset(memory_pool[i].data, 0, BLOCK_SIZE);
570
+ return memory_pool[i].data;
571
+ }
572
+ }
573
+ return NULL; // Pool exhausted
574
+ }
575
+
576
+ // Deterministic deallocation (O(1))
577
+ void pool_free(void* ptr) {
578
+ for (int i = 0; i < POOL_SIZE; i++) {
579
+ if (memory_pool[i].data == ptr) {
580
+ memory_pool[i].in_use = false;
581
+ return;
582
+ }
583
+ }
584
+ }
585
+
586
+ // Usage in real-time task
587
+ void realtime_task_with_pool(void *pvParameters) {
588
+ while (1) {
589
+ void* buffer = pool_alloc(); // Deterministic
590
+ if (buffer != NULL) {
591
+ process_data(buffer);
592
+ pool_free(buffer); // Deterministic
593
+ }
594
+
595
+ vTaskDelay(pdMS_TO_TICKS(10));
596
+ }
597
+ }
598
+ ```
599
+
600
+ ## References
601
+
602
+ - POSIX.1-2017 Real-Time Extensions
603
+ - Rate Monotonic Analysis (Liu & Layland)
604
+ - FreeRTOS Real-Time Kernel Documentation
605
+ - Real-Time Systems Design and Analysis (Phillip A. Laplante)
606
+ - Hard Real-Time Computing Systems (Giorgio Buttazzo)
607
+
608
+ ## Related Rules
609
+
610
+ - category-embedded
611
+ - universal-memory-safety
612
+ - category-systems
613
+
614
+ ## Configuration
615
+
616
+ Enable in `.augment/c-standards.json`:
617
+
618
+ ```json
619
+ {
620
+ "categories": ["realtime"],
621
+ "category_overrides": {
622
+ "realtime": {
623
+ "require_deterministic_timing": true,
624
+ "prohibit_unbounded_loops": true,
625
+ "require_priority_inheritance": true,
626
+ "max_critical_section_us": 10
627
+ }
628
+ }
629
+ }
630
+ ```
631
+