devworkspace 0.5.1 → 0.5.2

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 (380) hide show
  1. package/CHANGELOG.md +30 -2
  2. package/README.md +57 -509
  3. package/dist/agents/claude/adapter.js +0 -1
  4. package/dist/agents/claude/content.js +0 -1
  5. package/dist/agents/codex/adapter.js +0 -1
  6. package/dist/agents/copilot/adapter.js +0 -1
  7. package/dist/agents/cursor/adapter.js +0 -1
  8. package/dist/agents/index.js +0 -1
  9. package/dist/agents/shared.js +0 -1
  10. package/dist/agents/types.js +0 -1
  11. package/dist/cli/args.d.ts +16 -0
  12. package/dist/cli/args.js +5 -1
  13. package/dist/cli/help.js +59 -17
  14. package/dist/cli/main.js +0 -1
  15. package/dist/cli/prompt.d.ts +15 -0
  16. package/dist/cli/prompt.js +113 -0
  17. package/dist/cli/render.d.ts +10 -0
  18. package/dist/cli/render.js +174 -4
  19. package/dist/cli/run.d.ts +3 -0
  20. package/dist/cli/run.js +366 -17
  21. package/dist/config/feature-gate.d.ts +15 -0
  22. package/dist/config/feature-gate.js +77 -0
  23. package/dist/config/feature-registry.d.ts +49 -0
  24. package/dist/config/feature-registry.js +451 -0
  25. package/dist/config/schemas.js +0 -1
  26. package/dist/config/settings.d.ts +54 -0
  27. package/dist/config/settings.js +293 -0
  28. package/dist/config/validate.js +0 -1
  29. package/dist/core/artifacts.js +0 -1
  30. package/dist/core/contracts.js +0 -1
  31. package/dist/core/migrations.js +0 -1
  32. package/dist/core/version.js +0 -1
  33. package/dist/core/versioned.js +0 -1
  34. package/dist/core/workspace.d.ts +1 -0
  35. package/dist/core/workspace.js +1 -1
  36. package/dist/decisions/decision.js +0 -1
  37. package/dist/discovery/cache.js +0 -1
  38. package/dist/discovery/commands.js +0 -1
  39. package/dist/discovery/detect.js +0 -1
  40. package/dist/discovery/docs.js +0 -1
  41. package/dist/discovery/entrypoints.js +0 -1
  42. package/dist/discovery/ignore.js +0 -1
  43. package/dist/discovery/scan.js +0 -1
  44. package/dist/discovery/types.js +0 -1
  45. package/dist/dx/dashboard.js +2 -1
  46. package/dist/dx/guidance.js +0 -1
  47. package/dist/dx/guided-setup.d.ts +102 -0
  48. package/dist/dx/guided-setup.js +508 -0
  49. package/dist/dx/index.js +0 -1
  50. package/dist/dx/onboarding.js +0 -1
  51. package/dist/dx/types.js +0 -1
  52. package/dist/errors/index.js +0 -1
  53. package/dist/features/schema.js +0 -1
  54. package/dist/features/types.js +0 -1
  55. package/dist/features/validate.js +0 -1
  56. package/dist/git/git.js +0 -1
  57. package/dist/index.d.ts +15 -5
  58. package/dist/index.js +10 -2
  59. package/dist/integrations/adapters/agent-skills.js +0 -1
  60. package/dist/integrations/adapters/claudePlugin.js +0 -1
  61. package/dist/integrations/adapters/graphify.js +0 -1
  62. package/dist/integrations/adapters/omniroute.js +0 -1
  63. package/dist/integrations/adapters/pluginSkill.js +0 -1
  64. package/dist/integrations/adapters/ponytail.js +0 -1
  65. package/dist/integrations/exec.js +0 -1
  66. package/dist/integrations/index.js +0 -1
  67. package/dist/integrations/manager.d.ts +2 -1
  68. package/dist/integrations/manager.js +22 -3
  69. package/dist/integrations/notices.js +0 -1
  70. package/dist/integrations/persistentPath.js +0 -1
  71. package/dist/integrations/protect.js +0 -1
  72. package/dist/integrations/state.js +0 -1
  73. package/dist/integrations/types.d.ts +1 -1
  74. package/dist/integrations/types.js +1 -1
  75. package/dist/intelligence/agents/profiles.js +0 -1
  76. package/dist/intelligence/agents/registry.js +0 -1
  77. package/dist/intelligence/agents/types.js +0 -1
  78. package/dist/intelligence/observability/tracer.js +0 -1
  79. package/dist/intelligence/observability/types.js +0 -1
  80. package/dist/intelligence/orchestration/engine.d.ts +13 -4
  81. package/dist/intelligence/orchestration/engine.js +332 -54
  82. package/dist/intelligence/orchestration/lock-manager.js +0 -1
  83. package/dist/intelligence/orchestration/store.js +0 -1
  84. package/dist/intelligence/orchestration/types.d.ts +28 -1
  85. package/dist/intelligence/orchestration/types.js +0 -1
  86. package/dist/intelligence/routing/matcher.js +0 -1
  87. package/dist/intelligence/routing/router.js +0 -1
  88. package/dist/intelligence/routing/types.js +0 -1
  89. package/dist/intelligence/runtime/adk/adapter.js +1 -2
  90. package/dist/intelligence/runtime/adk/detector.js +0 -1
  91. package/dist/intelligence/runtime/auth-provider.d.ts +63 -0
  92. package/dist/intelligence/runtime/auth-provider.js +201 -0
  93. package/dist/intelligence/runtime/boundary.d.ts +118 -6
  94. package/dist/intelligence/runtime/boundary.js +720 -38
  95. package/dist/intelligence/runtime/changes.d.ts +59 -0
  96. package/dist/intelligence/runtime/changes.js +362 -0
  97. package/dist/intelligence/runtime/external.d.ts +1 -0
  98. package/dist/intelligence/runtime/external.js +9 -6
  99. package/dist/intelligence/runtime/native.js +0 -1
  100. package/dist/intelligence/runtime/types.d.ts +64 -2
  101. package/dist/intelligence/runtime/types.js +0 -1
  102. package/dist/intelligence/security/audit.js +8 -2
  103. package/dist/intelligence/security/policy.js +0 -1
  104. package/dist/intelligence/security/types.d.ts +8 -0
  105. package/dist/intelligence/security/types.js +0 -1
  106. package/dist/intelligence/skills/builtins.js +0 -1
  107. package/dist/intelligence/skills/loader.js +0 -1
  108. package/dist/intelligence/skills/registry.js +0 -1
  109. package/dist/intelligence/skills/types.js +0 -1
  110. package/dist/intelligence/verification/engine.d.ts +10 -2
  111. package/dist/intelligence/verification/engine.js +53 -9
  112. package/dist/intelligence/verification/reviewer.d.ts +18 -2
  113. package/dist/intelligence/verification/reviewer.js +356 -4
  114. package/dist/intelligence/verification/types.d.ts +60 -0
  115. package/dist/intelligence/verification/types.js +0 -1
  116. package/dist/knowledge/facts.js +0 -1
  117. package/dist/mcp/protocol.js +0 -1
  118. package/dist/mcp/server.js +38 -2
  119. package/dist/mcp/setup.js +5 -2
  120. package/dist/mcp/tools.js +0 -1
  121. package/dist/mcp/types.js +0 -1
  122. package/dist/mcp/verify.js +0 -1
  123. package/dist/portability/bundle.js +0 -1
  124. package/dist/prompts/onboarding.js +0 -1
  125. package/dist/prompts/refresh.js +0 -1
  126. package/dist/prompts/requirements.js +0 -1
  127. package/dist/security/files.js +0 -1
  128. package/dist/security/redact.js +0 -1
  129. package/dist/services/agent.js +2 -1
  130. package/dist/services/analysis.js +0 -1
  131. package/dist/services/common.js +0 -1
  132. package/dist/services/doctor.js +13 -2
  133. package/dist/services/drift.js +0 -1
  134. package/dist/services/features.js +5 -1
  135. package/dist/services/graph.js +4 -1
  136. package/dist/services/init.js +0 -1
  137. package/dist/services/integrations.d.ts +2 -1
  138. package/dist/services/integrations.js +29 -6
  139. package/dist/services/intelligence.d.ts +2 -2
  140. package/dist/services/intelligence.js +38 -36
  141. package/dist/services/knowledge.js +0 -1
  142. package/dist/services/migrate.js +0 -1
  143. package/dist/services/modules.d.ts +85 -0
  144. package/dist/services/modules.js +313 -0
  145. package/dist/services/portability.js +0 -1
  146. package/dist/services/records.js +5 -1
  147. package/dist/services/refresh.js +0 -1
  148. package/dist/services/reset.js +0 -1
  149. package/dist/services/settings.d.ts +36 -0
  150. package/dist/services/settings.js +102 -0
  151. package/dist/services/setup.d.ts +4 -5
  152. package/dist/services/setup.js +40 -28
  153. package/dist/services/standards.js +10 -1
  154. package/dist/services/status.js +0 -1
  155. package/dist/services/taskContext.js +0 -1
  156. package/dist/services/tasks.js +9 -1
  157. package/dist/services/verify.js +7 -2
  158. package/dist/sessions/session.js +0 -1
  159. package/dist/standards/acquisition/ingest.js +0 -1
  160. package/dist/standards/applicability/engine.js +0 -1
  161. package/dist/standards/builtin/code-quality.js +0 -1
  162. package/dist/standards/builtin/database-safety.js +0 -1
  163. package/dist/standards/builtin/index.js +0 -1
  164. package/dist/standards/builtin/security-baseline.js +0 -1
  165. package/dist/standards/builtin/testing-contracts.js +0 -1
  166. package/dist/standards/builtin/undo-kit.js +0 -1
  167. package/dist/standards/config/config.js +0 -1
  168. package/dist/standards/distribution/cache.js +0 -1
  169. package/dist/standards/distribution/index.js +0 -1
  170. package/dist/standards/distribution/keys.js +0 -1
  171. package/dist/standards/distribution/package.js +0 -1
  172. package/dist/standards/distribution/server.js +0 -1
  173. package/dist/standards/distribution/sync.js +0 -1
  174. package/dist/standards/distribution/types.js +0 -1
  175. package/dist/standards/engine/compliance.js +0 -1
  176. package/dist/standards/engine/engine.js +0 -1
  177. package/dist/standards/engine/reporter.js +0 -1
  178. package/dist/standards/index.js +0 -1
  179. package/dist/standards/registry/registry.js +0 -1
  180. package/dist/standards/schema/types.js +0 -1
  181. package/dist/standards/schema/validate.js +0 -1
  182. package/dist/standards/templates/index.js +0 -1
  183. package/dist/standards/validators/database.js +0 -1
  184. package/dist/standards/validators/quality.js +0 -1
  185. package/dist/standards/validators/registry.js +0 -1
  186. package/dist/standards/validators/security.js +0 -1
  187. package/dist/standards/validators/testing.js +0 -1
  188. package/dist/standards/validators/types.js +0 -1
  189. package/dist/standards/validators/undo-kit.js +0 -1
  190. package/dist/tasks/routing.js +0 -1
  191. package/dist/tasks/task.js +0 -1
  192. package/dist/utils/cleanup.js +0 -1
  193. package/dist/utils/fs.js +0 -1
  194. package/dist/utils/lock.js +92 -49
  195. package/dist/utils/logger.js +0 -1
  196. package/dist/utils/paths.js +0 -1
  197. package/dist/utils/proc.d.ts +8 -0
  198. package/dist/utils/proc.js +54 -46
  199. package/dist/verification/safety.js +0 -1
  200. package/dist/verification/scope.js +0 -1
  201. package/docs/architecture/global-standards-architecture.md +287 -0
  202. package/docs/archive/global-standards/GLOBAL_STANDARDS_AUDIT.md +99 -0
  203. package/docs/archive/global-standards/GLOBAL_STANDARDS_FINAL_STATUS.md +138 -0
  204. package/docs/archive/global-standards/GLOBAL_STANDARDS_IMPLEMENTATION_PLAN.md +100 -0
  205. package/docs/archive/global-standards/GLOBAL_STANDARDS_INDEPENDENT_AUDIT.md +219 -0
  206. package/docs/archive/global-standards/GLOBAL_STANDARDS_SECURITY_REPORT.md +184 -0
  207. package/docs/configuration.md +67 -0
  208. package/docs/contributing.md +15 -4
  209. package/docs/development/EXECUTION_STATE.md +50 -0
  210. package/docs/features.md +80 -0
  211. package/docs/getting-started.md +69 -111
  212. package/docs/guides/global-standards-migration.md +100 -0
  213. package/docs/integrations.md +7 -0
  214. package/docs/security/THIRD_PARTY_LICENSES.md +41 -0
  215. package/docs/testing/FINAL_CORRECTION_AND_CLEANUP_REPORT.md +92 -0
  216. package/docs/testing/global-standards-real-project-tests.md +218 -0
  217. package/docs/testing/global-standards-test-report.md +89 -0
  218. package/docs/testing/global-standards-verification-matrix.md +174 -0
  219. package/docs/troubleshooting.md +3 -0
  220. package/package.json +1 -1
  221. package/dist/agents/claude/adapter.js.map +0 -1
  222. package/dist/agents/claude/content.js.map +0 -1
  223. package/dist/agents/codex/adapter.js.map +0 -1
  224. package/dist/agents/copilot/adapter.js.map +0 -1
  225. package/dist/agents/cursor/adapter.js.map +0 -1
  226. package/dist/agents/index.js.map +0 -1
  227. package/dist/agents/shared.js.map +0 -1
  228. package/dist/agents/types.js.map +0 -1
  229. package/dist/cli/args.js.map +0 -1
  230. package/dist/cli/help.js.map +0 -1
  231. package/dist/cli/main.js.map +0 -1
  232. package/dist/cli/render.js.map +0 -1
  233. package/dist/cli/run.js.map +0 -1
  234. package/dist/config/schemas.js.map +0 -1
  235. package/dist/config/validate.js.map +0 -1
  236. package/dist/core/artifacts.js.map +0 -1
  237. package/dist/core/contracts.js.map +0 -1
  238. package/dist/core/migrations.js.map +0 -1
  239. package/dist/core/version.js.map +0 -1
  240. package/dist/core/versioned.js.map +0 -1
  241. package/dist/core/workspace.js.map +0 -1
  242. package/dist/decisions/decision.js.map +0 -1
  243. package/dist/discovery/cache.js.map +0 -1
  244. package/dist/discovery/commands.js.map +0 -1
  245. package/dist/discovery/detect.js.map +0 -1
  246. package/dist/discovery/docs.js.map +0 -1
  247. package/dist/discovery/entrypoints.js.map +0 -1
  248. package/dist/discovery/ignore.js.map +0 -1
  249. package/dist/discovery/scan.js.map +0 -1
  250. package/dist/discovery/types.js.map +0 -1
  251. package/dist/dx/dashboard.js.map +0 -1
  252. package/dist/dx/guidance.js.map +0 -1
  253. package/dist/dx/index.js.map +0 -1
  254. package/dist/dx/onboarding.js.map +0 -1
  255. package/dist/dx/types.js.map +0 -1
  256. package/dist/errors/index.js.map +0 -1
  257. package/dist/features/schema.js.map +0 -1
  258. package/dist/features/types.js.map +0 -1
  259. package/dist/features/validate.js.map +0 -1
  260. package/dist/git/git.js.map +0 -1
  261. package/dist/index.js.map +0 -1
  262. package/dist/integrations/adapters/agent-skills.js.map +0 -1
  263. package/dist/integrations/adapters/claudePlugin.js.map +0 -1
  264. package/dist/integrations/adapters/graphify.js.map +0 -1
  265. package/dist/integrations/adapters/omniroute.js.map +0 -1
  266. package/dist/integrations/adapters/pluginSkill.js.map +0 -1
  267. package/dist/integrations/adapters/ponytail.js.map +0 -1
  268. package/dist/integrations/exec.js.map +0 -1
  269. package/dist/integrations/index.js.map +0 -1
  270. package/dist/integrations/manager.js.map +0 -1
  271. package/dist/integrations/notices.js.map +0 -1
  272. package/dist/integrations/persistentPath.js.map +0 -1
  273. package/dist/integrations/protect.js.map +0 -1
  274. package/dist/integrations/state.js.map +0 -1
  275. package/dist/integrations/types.js.map +0 -1
  276. package/dist/intelligence/agents/profiles.js.map +0 -1
  277. package/dist/intelligence/agents/registry.js.map +0 -1
  278. package/dist/intelligence/agents/types.js.map +0 -1
  279. package/dist/intelligence/observability/tracer.js.map +0 -1
  280. package/dist/intelligence/observability/types.js.map +0 -1
  281. package/dist/intelligence/orchestration/engine.js.map +0 -1
  282. package/dist/intelligence/orchestration/lock-manager.js.map +0 -1
  283. package/dist/intelligence/orchestration/store.js.map +0 -1
  284. package/dist/intelligence/orchestration/types.js.map +0 -1
  285. package/dist/intelligence/routing/matcher.js.map +0 -1
  286. package/dist/intelligence/routing/router.js.map +0 -1
  287. package/dist/intelligence/routing/types.js.map +0 -1
  288. package/dist/intelligence/runtime/adk/adapter.js.map +0 -1
  289. package/dist/intelligence/runtime/adk/detector.js.map +0 -1
  290. package/dist/intelligence/runtime/boundary.js.map +0 -1
  291. package/dist/intelligence/runtime/external.js.map +0 -1
  292. package/dist/intelligence/runtime/native.js.map +0 -1
  293. package/dist/intelligence/runtime/types.js.map +0 -1
  294. package/dist/intelligence/security/audit.js.map +0 -1
  295. package/dist/intelligence/security/policy.js.map +0 -1
  296. package/dist/intelligence/security/types.js.map +0 -1
  297. package/dist/intelligence/skills/builtins.js.map +0 -1
  298. package/dist/intelligence/skills/loader.js.map +0 -1
  299. package/dist/intelligence/skills/registry.js.map +0 -1
  300. package/dist/intelligence/skills/types.js.map +0 -1
  301. package/dist/intelligence/verification/engine.js.map +0 -1
  302. package/dist/intelligence/verification/reviewer.js.map +0 -1
  303. package/dist/intelligence/verification/types.js.map +0 -1
  304. package/dist/knowledge/facts.js.map +0 -1
  305. package/dist/mcp/protocol.js.map +0 -1
  306. package/dist/mcp/server.js.map +0 -1
  307. package/dist/mcp/setup.js.map +0 -1
  308. package/dist/mcp/tools.js.map +0 -1
  309. package/dist/mcp/types.js.map +0 -1
  310. package/dist/mcp/verify.js.map +0 -1
  311. package/dist/portability/bundle.js.map +0 -1
  312. package/dist/prompts/onboarding.js.map +0 -1
  313. package/dist/prompts/refresh.js.map +0 -1
  314. package/dist/prompts/requirements.js.map +0 -1
  315. package/dist/security/files.js.map +0 -1
  316. package/dist/security/redact.js.map +0 -1
  317. package/dist/services/agent.js.map +0 -1
  318. package/dist/services/analysis.js.map +0 -1
  319. package/dist/services/common.js.map +0 -1
  320. package/dist/services/doctor.js.map +0 -1
  321. package/dist/services/drift.js.map +0 -1
  322. package/dist/services/features.js.map +0 -1
  323. package/dist/services/graph.js.map +0 -1
  324. package/dist/services/init.js.map +0 -1
  325. package/dist/services/integrations.js.map +0 -1
  326. package/dist/services/intelligence.js.map +0 -1
  327. package/dist/services/knowledge.js.map +0 -1
  328. package/dist/services/migrate.js.map +0 -1
  329. package/dist/services/portability.js.map +0 -1
  330. package/dist/services/records.js.map +0 -1
  331. package/dist/services/refresh.js.map +0 -1
  332. package/dist/services/reset.js.map +0 -1
  333. package/dist/services/setup.js.map +0 -1
  334. package/dist/services/standards.js.map +0 -1
  335. package/dist/services/status.js.map +0 -1
  336. package/dist/services/taskContext.js.map +0 -1
  337. package/dist/services/tasks.js.map +0 -1
  338. package/dist/services/verify.js.map +0 -1
  339. package/dist/sessions/session.js.map +0 -1
  340. package/dist/standards/acquisition/ingest.js.map +0 -1
  341. package/dist/standards/applicability/engine.js.map +0 -1
  342. package/dist/standards/builtin/code-quality.js.map +0 -1
  343. package/dist/standards/builtin/database-safety.js.map +0 -1
  344. package/dist/standards/builtin/index.js.map +0 -1
  345. package/dist/standards/builtin/security-baseline.js.map +0 -1
  346. package/dist/standards/builtin/testing-contracts.js.map +0 -1
  347. package/dist/standards/builtin/undo-kit.js.map +0 -1
  348. package/dist/standards/config/config.js.map +0 -1
  349. package/dist/standards/distribution/cache.js.map +0 -1
  350. package/dist/standards/distribution/index.js.map +0 -1
  351. package/dist/standards/distribution/keys.js.map +0 -1
  352. package/dist/standards/distribution/package.js.map +0 -1
  353. package/dist/standards/distribution/server.js.map +0 -1
  354. package/dist/standards/distribution/sync.js.map +0 -1
  355. package/dist/standards/distribution/types.js.map +0 -1
  356. package/dist/standards/engine/compliance.js.map +0 -1
  357. package/dist/standards/engine/engine.js.map +0 -1
  358. package/dist/standards/engine/reporter.js.map +0 -1
  359. package/dist/standards/index.js.map +0 -1
  360. package/dist/standards/registry/registry.js.map +0 -1
  361. package/dist/standards/schema/types.js.map +0 -1
  362. package/dist/standards/schema/validate.js.map +0 -1
  363. package/dist/standards/templates/index.js.map +0 -1
  364. package/dist/standards/validators/database.js.map +0 -1
  365. package/dist/standards/validators/quality.js.map +0 -1
  366. package/dist/standards/validators/registry.js.map +0 -1
  367. package/dist/standards/validators/security.js.map +0 -1
  368. package/dist/standards/validators/testing.js.map +0 -1
  369. package/dist/standards/validators/types.js.map +0 -1
  370. package/dist/standards/validators/undo-kit.js.map +0 -1
  371. package/dist/tasks/routing.js.map +0 -1
  372. package/dist/tasks/task.js.map +0 -1
  373. package/dist/utils/cleanup.js.map +0 -1
  374. package/dist/utils/fs.js.map +0 -1
  375. package/dist/utils/lock.js.map +0 -1
  376. package/dist/utils/logger.js.map +0 -1
  377. package/dist/utils/paths.js.map +0 -1
  378. package/dist/utils/proc.js.map +0 -1
  379. package/dist/verification/safety.js.map +0 -1
  380. package/dist/verification/scope.js.map +0 -1
@@ -1,8 +1,10 @@
1
+ import { randomBytes } from 'node:crypto';
1
2
  import { promises as fs, unlinkSync } from 'node:fs';
2
3
  import path from 'node:path';
3
4
  import { DevWorkspaceError } from '../errors/index.js';
4
5
  import { ensureDir } from './fs.js';
5
6
  import { onCleanup } from './cleanup.js';
7
+ const localLockQueues = new Map();
6
8
  function pidAlive(pid) {
7
9
  try {
8
10
  process.kill(pid, 0);
@@ -18,68 +20,109 @@ export async function withLock(workspaceDir, fn, opts = {}) {
18
20
  const staleMs = opts.staleMs ?? 60_000;
19
21
  const dir = path.join(workspaceDir, 'local');
20
22
  const lockPath = path.join(dir, opts.name ?? 'workspace.lock');
21
- await ensureDir(dir);
22
- const started = Date.now();
23
- let winPermRetries = 0;
24
- for (;;) {
25
- try {
26
- const fh = await fs.open(lockPath, 'wx');
27
- await fh.writeFile(JSON.stringify({ pid: process.pid, at: Date.now() }));
28
- await fh.close();
29
- break;
30
- }
31
- catch (e) {
32
- const code = e.code;
33
- // On Windows, opening a recently unlinked lock file while its handle is closing can briefly raise EPERM/EACCES.
34
- if (process.platform === 'win32' && (code === 'EPERM' || code === 'EACCES') && winPermRetries < 25 && Date.now() - started <= timeoutMs) {
35
- winPermRetries++;
36
- await new Promise((r) => setTimeout(r, 15 + Math.floor(Math.random() * 25)));
37
- continue;
38
- }
39
- if (code !== 'EEXIST') {
40
- throw new DevWorkspaceError('IO', 'Could not acquire the workspace lock.', { cause: e });
41
- }
42
- let stale;
23
+ const queueKey = process.platform === 'win32' ? path.resolve(lockPath).toLowerCase() : path.resolve(lockPath);
24
+ const myToken = randomBytes(8).toString('hex');
25
+ const previous = localLockQueues.get(queueKey) ?? Promise.resolve();
26
+ let releaseLocal;
27
+ const currentSlot = new Promise((resolve) => {
28
+ releaseLocal = resolve;
29
+ });
30
+ const chained = previous.then(() => currentSlot);
31
+ localLockQueues.set(queueKey, chained);
32
+ await previous;
33
+ try {
34
+ await ensureDir(dir);
35
+ const started = Date.now();
36
+ let winPermRetries = 0;
37
+ for (;;) {
43
38
  try {
44
- const info = JSON.parse(await fs.readFile(lockPath, 'utf8'));
45
- const age = Date.now() - (info.at ?? 0);
46
- stale = age > staleMs || (typeof info.pid === 'number' && !pidAlive(info.pid));
39
+ const fh = await fs.open(lockPath, 'wx');
40
+ try {
41
+ await fh.writeFile(JSON.stringify({ pid: process.pid, at: Date.now(), token: myToken }));
42
+ }
43
+ finally {
44
+ await fh.close();
45
+ }
46
+ break;
47
47
  }
48
- catch {
49
- // Unreadable lock: another process may be mid-write, so only break it once it is old.
48
+ catch (e) {
49
+ const code = e.code;
50
+ // On Windows, opening a recently unlinked lock file while its handle is closing can briefly raise EPERM/EACCES.
51
+ if (process.platform === 'win32' && (code === 'EPERM' || code === 'EACCES') && winPermRetries < 25 && Date.now() - started <= timeoutMs) {
52
+ winPermRetries++;
53
+ await new Promise((r) => setTimeout(r, 15 + Math.floor(Math.random() * 25)));
54
+ continue;
55
+ }
56
+ if (code !== 'EEXIST') {
57
+ throw new DevWorkspaceError('IO', 'Could not acquire the workspace lock.', { cause: e });
58
+ }
59
+ let stale = false;
60
+ let disappeared = false;
50
61
  try {
51
- stale = Date.now() - (await fs.stat(lockPath)).mtimeMs > 2000;
62
+ const info = JSON.parse(await fs.readFile(lockPath, 'utf8'));
63
+ const age = Date.now() - (info.at ?? 0);
64
+ stale = age > staleMs || (typeof info.pid === 'number' && !pidAlive(info.pid));
52
65
  }
53
66
  catch {
54
- stale = true;
67
+ // Unreadable lock: another process may be mid-write, or the lock was just released.
68
+ try {
69
+ stale = Date.now() - (await fs.stat(lockPath)).mtimeMs > 2000;
70
+ }
71
+ catch {
72
+ disappeared = true;
73
+ }
74
+ }
75
+ if (disappeared) {
76
+ continue;
77
+ }
78
+ if (stale) {
79
+ const staleTrash = `${lockPath}.stale.${randomBytes(4).toString('hex')}`;
80
+ try {
81
+ await fs.rename(lockPath, staleTrash);
82
+ await fs.rm(staleTrash, { force: true }).catch(() => undefined);
83
+ }
84
+ catch {
85
+ // Another waiter already broke or removed the lock; retry cleanly.
86
+ }
87
+ continue;
55
88
  }
89
+ if (Date.now() - started > timeoutMs) {
90
+ throw new DevWorkspaceError('LOCKED', 'Another DevWorkspace process is modifying this workspace.', {
91
+ hint: `Wait for it to finish, or delete ${path.join('.devworkspace', 'local', opts.name ?? 'workspace.lock')} if no process is running.`,
92
+ });
93
+ }
94
+ await new Promise((r) => setTimeout(r, 25 + Math.floor(Math.random() * 50)));
56
95
  }
57
- if (stale) {
58
- await fs.rm(lockPath, { force: true });
59
- continue;
96
+ }
97
+ const dispose = onCleanup(() => {
98
+ try {
99
+ unlinkSync(lockPath);
60
100
  }
61
- if (Date.now() - started > timeoutMs) {
62
- throw new DevWorkspaceError('LOCKED', 'Another DevWorkspace process is modifying this workspace.', {
63
- hint: `Wait for it to finish, or delete ${path.join('.devworkspace', 'local', opts.name ?? 'workspace.lock')} if no process is running.`,
64
- });
101
+ catch {
102
+ /* already gone */
65
103
  }
66
- await new Promise((r) => setTimeout(r, 25 + Math.floor(Math.random() * 50)));
67
- }
68
- }
69
- const dispose = onCleanup(() => {
104
+ });
70
105
  try {
71
- unlinkSync(lockPath);
106
+ return await fn();
72
107
  }
73
- catch {
74
- /* already gone */
108
+ finally {
109
+ dispose();
110
+ try {
111
+ const raw = await fs.readFile(lockPath, 'utf8');
112
+ const info = JSON.parse(raw);
113
+ if (info.token === myToken) {
114
+ await fs.rm(lockPath, { force: true }).catch(() => undefined);
115
+ }
116
+ }
117
+ catch {
118
+ // Lock was already removed (e.g. via cleanup hook or external stale break).
119
+ }
75
120
  }
76
- });
77
- try {
78
- return await fn();
79
121
  }
80
122
  finally {
81
- dispose();
82
- await fs.rm(lockPath, { force: true }).catch(() => undefined);
123
+ releaseLocal();
124
+ if (localLockQueues.get(queueKey) === chained) {
125
+ localLockQueues.delete(queueKey);
126
+ }
83
127
  }
84
128
  }
85
- //# sourceMappingURL=lock.js.map
@@ -15,4 +15,3 @@ export function createLogger(level, write = (l) => process.stderr.write(l + '\n'
15
15
  };
16
16
  }
17
17
  export const silentLogger = createLogger('error', () => undefined);
18
- //# sourceMappingURL=logger.js.map
@@ -121,4 +121,3 @@ export function findAbsolutePaths(text) {
121
121
  const hits = text.match(/(?:\b[A-Za-z]:\\[^\s"'`<>|]+|\/(?:Users|home)\/[^\s"'`<>|]+)/g);
122
122
  return hits ? [...new Set(hits)] : [];
123
123
  }
124
- //# sourceMappingURL=paths.js.map
@@ -22,6 +22,14 @@ export interface RunOptions {
22
22
  }
23
23
  /** Build a minimal process environment containing OS/runtime basics without leaking secrets. */
24
24
  export declare function createMinimalExecutionEnv(baseEnv?: NodeJS.ProcessEnv, extraAllowKeys?: string[], overrides?: Record<string, string | undefined>): NodeJS.ProcessEnv;
25
+ /**
26
+ * Spawn an executable with an argument array without blocking on child exit until `done` is awaited.
27
+ * Never uses a shell, so project- or user-supplied values cannot be interpreted as shell syntax.
28
+ */
29
+ export declare function startRun(command: string, args: string[], opts?: RunOptions): {
30
+ spawned: boolean;
31
+ done: Promise<RunResult>;
32
+ };
25
33
  /**
26
34
  * Run an executable with an argument array. Never uses a shell, so project- or
27
35
  * user-supplied values cannot be interpreted as shell syntax.
@@ -53,64 +53,65 @@ function killProcessTree(child) {
53
53
  }
54
54
  }
55
55
  /**
56
- * Run an executable with an argument array. Never uses a shell, so project- or
57
- * user-supplied values cannot be interpreted as shell syntax.
56
+ * Spawn an executable with an argument array without blocking on child exit until `done` is awaited.
57
+ * Never uses a shell, so project- or user-supplied values cannot be interpreted as shell syntax.
58
58
  */
59
- export function run(command, args, opts = {}) {
59
+ export function startRun(command, args, opts = {}) {
60
60
  const timeoutMs = opts.timeoutMs ?? 15_000;
61
61
  const maxBytes = opts.maxBytes ?? 4 * 1024 * 1024;
62
- return new Promise((resolve) => {
63
- let stdout = '';
64
- let stderr = '';
65
- let timedOut = false;
66
- let aborted = false;
67
- let settled = false;
68
- // eslint-disable-next-line prefer-const -- assigned after spawn; finish() may run first if spawn throws
69
- let timer;
62
+ let stdout = '';
63
+ let stderr = '';
64
+ let timedOut = false;
65
+ let aborted = false;
66
+ let settled = false;
67
+ if (opts.signal?.aborted) {
68
+ return {
69
+ spawned: false,
70
+ done: Promise.resolve({ ok: false, code: null, stdout, stderr, timedOut: false, aborted: true, error: 'aborted' }),
71
+ };
72
+ }
73
+ let child;
74
+ try {
75
+ const env = opts.replaceEnv
76
+ ? { ...(opts.env ?? {}) }
77
+ : opts.env ? { ...process.env, ...opts.env } : process.env;
78
+ for (const [k, v] of Object.entries(env))
79
+ if (v === undefined)
80
+ delete env[k];
81
+ child = spawn(command, args, {
82
+ cwd: opts.cwd,
83
+ env,
84
+ shell: false,
85
+ windowsHide: true,
86
+ windowsVerbatimArguments: opts.windowsVerbatimArguments,
87
+ detached: process.platform !== 'win32',
88
+ stdio: ['ignore', 'pipe', 'pipe'],
89
+ });
90
+ }
91
+ catch (e) {
92
+ return {
93
+ spawned: false,
94
+ done: Promise.resolve({ ok: false, code: null, stdout, stderr, timedOut: false, error: e.message }),
95
+ };
96
+ }
97
+ const c = child;
98
+ const done = new Promise((resolve) => {
70
99
  const onAbort = () => {
71
100
  aborted = true;
72
- killProcessTree(child);
101
+ killProcessTree(c);
73
102
  };
103
+ const timer = setTimeout(() => {
104
+ timedOut = true;
105
+ killProcessTree(c);
106
+ }, timeoutMs);
74
107
  const finish = (r) => {
75
108
  if (settled)
76
109
  return;
77
110
  settled = true;
78
- if (timer)
79
- clearTimeout(timer);
111
+ clearTimeout(timer);
80
112
  opts.signal?.removeEventListener('abort', onAbort);
81
113
  resolve(aborted ? { ...r, ok: false, aborted: true } : r);
82
114
  };
83
- let child;
84
- if (opts.signal?.aborted) {
85
- finish({ ok: false, code: null, stdout, stderr, timedOut: false, aborted: true, error: 'aborted' });
86
- return;
87
- }
88
- try {
89
- const env = opts.replaceEnv
90
- ? { ...(opts.env ?? {}) }
91
- : opts.env ? { ...process.env, ...opts.env } : process.env;
92
- for (const [k, v] of Object.entries(env))
93
- if (v === undefined)
94
- delete env[k];
95
- child = spawn(command, args, {
96
- cwd: opts.cwd,
97
- env,
98
- shell: false,
99
- windowsHide: true,
100
- windowsVerbatimArguments: opts.windowsVerbatimArguments,
101
- detached: process.platform !== 'win32',
102
- stdio: ['ignore', 'pipe', 'pipe'],
103
- });
104
- }
105
- catch (e) {
106
- finish({ ok: false, code: null, stdout, stderr, timedOut: false, error: e.message });
107
- return;
108
- }
109
- const c = child;
110
- timer = setTimeout(() => {
111
- timedOut = true;
112
- killProcessTree(c);
113
- }, timeoutMs);
114
115
  opts.signal?.addEventListener('abort', onAbort, { once: true });
115
116
  c.stdout?.on('data', (d) => {
116
117
  if (stdout.length < maxBytes)
@@ -123,6 +124,14 @@ export function run(command, args, opts = {}) {
123
124
  c.on('error', (e) => finish({ ok: false, code: null, stdout, stderr, timedOut, error: e.message }));
124
125
  c.on('close', (code) => finish({ ok: code === 0 && !timedOut && !aborted, code, stdout, stderr, timedOut }));
125
126
  });
127
+ return { spawned: true, done };
128
+ }
129
+ /**
130
+ * Run an executable with an argument array. Never uses a shell, so project- or
131
+ * user-supplied values cannot be interpreted as shell syntax.
132
+ */
133
+ export function run(command, args, opts = {}) {
134
+ return startRun(command, args, opts).done;
126
135
  }
127
136
  /** Locate an executable on PATH (honouring PATHEXT on Windows) without executing anything. */
128
137
  export async function which(name, env = process.env) {
@@ -166,4 +175,3 @@ export async function which(name, env = process.env) {
166
175
  export function isShellShim(file) {
167
176
  return /\.(cmd|bat)$/i.test(file);
168
177
  }
169
- //# sourceMappingURL=proc.js.map
@@ -117,4 +117,3 @@ export async function removeDeclaration(ws, pkg) {
117
117
  export function isDeclared(decls, pkg, check) {
118
118
  return decls.find((d) => d.package === pkg && d.checks.includes(check));
119
119
  }
120
- //# sourceMappingURL=safety.js.map
@@ -116,4 +116,3 @@ export function scopeByPackage(changes, contract) {
116
116
  }
117
117
  return out;
118
118
  }
119
- //# sourceMappingURL=scope.js.map
@@ -0,0 +1,287 @@
1
+ # DevWorkspace Global Engineering Standards & Knowledge System
2
+ ## System Architecture & Technical Specification
3
+
4
+ **Version:** 1.0.0
5
+ **Status:** Approved Architecture
6
+ **Author:** Principal Software Architect & Senior TypeScript Engineer
7
+ **Date:** 2026-11-30
8
+
9
+ ---
10
+
11
+ ## 1. System Vision & High-Level Architecture
12
+
13
+ The **DevWorkspace Global Engineering Standards System** is a native, offline-first, technology-independent governance and quality engineering platform built directly into the DevWorkspace core.
14
+
15
+ It shifts software engineering governance from subjective manual guidelines or unpredictable LLM suggestions into deterministic, automated, version-controlled standards with executable validators.
16
+
17
+ ```text
18
+ +------------------------------------------------------------------------------------------------+
19
+ | DEVWORKSPACE CLI & RUNTIME |
20
+ | devworkspace standards <list | show | audit | check | apply | add | update | report | validate> |
21
+ +------------------------------------------------------------------------------------------------+
22
+ |
23
+ v
24
+ +------------------------------------------------------------------------------------------------+
25
+ | STANDARDS SERVICE LAYER |
26
+ | (src/services/standards.ts) |
27
+ +------------------------------------------------------------------------------------------------+
28
+ | | |
29
+ v v v
30
+ +-----------------------+ +-----------------------+ +-----------------------+
31
+ | STANDARDS REGISTRY | | APPLICABILITY ENGINE | | VALIDATION ENGINE |
32
+ | (src/standards/ | | (src/standards/ | | (src/standards/ |
33
+ | registry/) | | applicability/) | | validators/) |
34
+ | | | | | |
35
+ | - Built-in Standards | | - Tech Detection | | - Security Validator |
36
+ | - Local Custom Rules | | - Arch Patterns | | - DB Migration Guard |
37
+ | - Version Management | | - Framework Rules | | - Testing Validator |
38
+ | - Lifecycle Transitions | - Applicability Match | | - Undo Kit Validator |
39
+ +-----------------------+ +-----------------------+ | - Code Quality Guard |
40
+ | | +-----------------------+
41
+ +-----------------+------------------+ |
42
+ v v
43
+ +------------------------------------------------------------------------------------------------+
44
+ | STANDARDS CORE ENGINE |
45
+ | (src/standards/engine/) |
46
+ | |
47
+ | 1. Configuration Inheritance: Global Defaults -> Tech-Specific -> Project -> Exceptions |
48
+ | 2. Compliance Scoring: (Passed Checks / Total Applicable Checks) * 100% |
49
+ | 3. Violation & Remediation Aggregator |
50
+ | 4. Markdown & JSON Compliance Report Generator |
51
+ +------------------------------------------------------------------------------------------------+
52
+ ```
53
+
54
+ ---
55
+
56
+ ## 2. Core Subsystems & Components
57
+
58
+ ### 2.1 Standards Schema & Lifecycle (`src/standards/schema/types.ts`)
59
+
60
+ Every engineering standard is governed by a strict TypeScript schema:
61
+
62
+ ```typescript
63
+ export type StandardCategory =
64
+ | 'architecture'
65
+ | 'security'
66
+ | 'database'
67
+ | 'development'
68
+ | 'code-quality'
69
+ | 'testing'
70
+ | 'devops'
71
+ | 'deployment'
72
+ | 'performance'
73
+ | 'scalability'
74
+ | 'observability'
75
+ | 'documentation'
76
+ | 'accessibility'
77
+ | 'reliability'
78
+ | 'recovery';
79
+
80
+ export type StandardStatus =
81
+ | 'DRAFT'
82
+ | 'REVIEW'
83
+ | 'APPROVED'
84
+ | 'DEPRECATED'
85
+ | 'ARCHIVED';
86
+
87
+ export type EnforcementLevel =
88
+ | 'required'
89
+ | 'recommended'
90
+ | 'optional';
91
+
92
+ export interface ApplicabilityCriteria {
93
+ ecosystems?: string[]; // e.g. ['node', 'python', 'rust']
94
+ frameworks?: string[]; // e.g. ['express', 'fastify', 'react', 'nextjs']
95
+ databases?: string[]; // e.g. ['prisma', 'postgresql', 'supabase', 'mongodb']
96
+ platforms?: string[]; // e.g. ['vercel', 'netlify', 'docker', 'aws']
97
+ appTypes?: string[]; // e.g. ['api', 'spa', 'monorepo', 'cli']
98
+ filePatterns?: string[]; // e.g. ['prisma/schema.prisma', 'Dockerfile']
99
+ all?: boolean; // Universal standard (applies to all projects)
100
+ }
101
+
102
+ export interface StandardRule {
103
+ id: string; // e.g. 'deployment.backup-first'
104
+ title: string;
105
+ description: string;
106
+ severity: 'critical' | 'high' | 'medium' | 'low' | 'info';
107
+ enforcement: EnforcementLevel;
108
+ remediation: string;
109
+ validatorId?: string; // Linked executable validator ID
110
+ }
111
+
112
+ export interface EngineeringStandard {
113
+ id: string; // kebab-case identifier, e.g. 'deployment-safety-and-rollback'
114
+ name: string;
115
+ description: string;
116
+ category: StandardCategory;
117
+ version: string; // semver string, e.g. '1.0.0'
118
+ status: StandardStatus;
119
+ applicability: ApplicabilityCriteria;
120
+ requirements: string[];
121
+ guidelines: string[];
122
+ rules: StandardRule[];
123
+ enforcement: EnforcementLevel;
124
+ references: string[];
125
+ metadata: {
126
+ createdAt: string;
127
+ updatedAt: string;
128
+ author: string;
129
+ tags: string[];
130
+ };
131
+ }
132
+ ```
133
+
134
+ #### Lifecycle State Machine
135
+ ```text
136
+ [ DRAFT ] ──(Submit for Review)──> [ REVIEW ] ──(Approved by Maintainer)──> [ APPROVED ]
137
+ │
138
+ (Superseded / Outdated)
139
+ │
140
+ v
141
+ [ ARCHIVED ] ◄────────────────(Final Archive)─────────────────────────── [ DEPRECATED ]
142
+ ```
143
+
144
+ ---
145
+
146
+ ### 2.2 Standards Registry (`src/standards/registry/`)
147
+ The Standards Registry manages both built-in standards and local project/user custom standards:
148
+ - **Built-in Standards:** High-quality, peer-reviewed engineering standards bundled directly in the package (including `deployment-safety-and-rollback`, `security-baseline`, `database-expand-and-contract`, `testing-contract-safety`, `code-quality-static-analysis`).
149
+ - **Project Standards:** Stored under `.devworkspace/standards/custom/*.json`.
150
+ - **Global User Standards:** Stored under `~/.devworkspace/standards/*.json`.
151
+ - **Registry Capabilities:**
152
+ - `get(id: string)`: Retrieves standard by ID.
153
+ - `list(filter?)`: Returns all registered standards matching category or status.
154
+ - `validateRegistry()`: Guarantees structural integrity, unique IDs, valid semver, and matching validator IDs.
155
+ - `register(standard)`: Adds or overrides a standard definition.
156
+
157
+ ---
158
+
159
+ ### 2.3 Project Applicability Engine (`src/standards/applicability/`)
160
+ Determines which standards apply to the current project:
161
+ 1. Reuses and inspects `DiscoveryReport` from `src/discovery/detect.ts`.
162
+ 2. Matches project properties against each standard's `ApplicabilityCriteria`:
163
+ - Checks if `criteria.all === true`.
164
+ - Checks if any project ecosystem matches `criteria.ecosystems`.
165
+ - Checks if any detected framework or database matches `criteria.frameworks` or `criteria.databases`.
166
+ - Checks if required files exist (`criteria.filePatterns`).
167
+ 3. Produces an `ApplicabilityResult`:
168
+ - `applicableStandards`: List of matching standards.
169
+ - `excludedStandards`: Standards not applicable, with transparent reasoning.
170
+ - `detectedTechnologies`: Summary of detected stacks.
171
+
172
+ ---
173
+
174
+ ### 2.4 Executable Validation Engine (`src/standards/validators/`)
175
+ Validators are **executable functions**, not passive text checklists:
176
+
177
+ ```typescript
178
+ export interface ValidationEvidence {
179
+ file?: string;
180
+ line?: number;
181
+ snippet?: string;
182
+ command?: string;
183
+ details?: Record<string, unknown>;
184
+ }
185
+
186
+ export interface ValidationResult {
187
+ ruleId: string;
188
+ standardId: string;
189
+ title: string;
190
+ status: 'PASS' | 'WARN' | 'FAIL' | 'SKIPPED';
191
+ severity: 'critical' | 'high' | 'medium' | 'low' | 'info';
192
+ message: string;
193
+ evidence?: ValidationEvidence;
194
+ remediation?: string;
195
+ }
196
+
197
+ export type ValidatorFn = (context: ValidatorContext) => Promise<ValidationResult[]>;
198
+ ```
199
+
200
+ #### Initial Executable Validators
201
+ 1. **The Undo Kit & Deployment Safety:**
202
+ - `deployment.rollback-plan`: Verifies presence and contents of `ROLLBACK.md` (documents hosting rollback, database backup commands, feature flags, rehearsal record).
203
+ - `deployment.last-good-deploy`: Validates deployment hosting documentation (Vercel, Netlify, Docker, etc.).
204
+ - `deployment.backup-first`: Validates backup commands and prevents deployment without backup step.
205
+ - `deployment.feature-flags`: Detects feature switches/flags configuration in code or database schema.
206
+ 2. **Database Migration Safety (Expand-and-Contract):**
207
+ - `database.expand-and-contract`: Scans pending/recent SQL migrations and Prisma schemas for destructive operations (`DROP TABLE`, `DROP COLUMN`, `TRUNCATE`, `ALTER TABLE ... RENAME`). Flags them as FAIL or WARN, requiring expand-and-contract two-phase evolution.
208
+ 3. **Security Standards:**
209
+ - `security.secret-detection`: Deep scan for exposed API keys, private keys, and high-entropy credentials.
210
+ - `security.dependency-audit`: Evaluates production dependencies for known critical vulnerabilities.
211
+ - `security.sensitive-files`: Verifies credential files (`.env`, `.env.production`) are in `.gitignore`.
212
+ 4. **Testing Contracts:**
213
+ - `testing.test-availability`: Validates presence of unit/integration test suites.
214
+ - `testing.contract-verification`: Validates `commands.json` testing contract is non-vacuous.
215
+ 5. **Code Quality:**
216
+ - `code-quality.typecheck`: Strict TypeScript typechecking verification.
217
+ - `code-quality.lint`: Verification that linter runs without errors.
218
+
219
+ ---
220
+
221
+ ### 2.5 The Undo Kit Standard (`deployment-safety-and-rollback`)
222
+ Directly implements the 4 mechanisms from the canonical specification:
223
+ - **Button 1 (Last Good Deploy):** Instant rollback procedure documentation for Vercel, Netlify, Docker, or Cloudflare.
224
+ - **Button 2 (Backup First):** Pre-release database backup requirement, dump commands (`supabase db dump`, `pg_dump`, etc.), restore command into isolated test projects.
225
+ - **Button 3 (A Switch):** Feature flags table (`feature_flags` with `name` and `enabled`) or environment toggle, defaulting new features to `enabled = false`.
226
+ - **Button 4 (Try It Once / Recovery Rehearsal):** Rehearsal log in `ROLLBACK.md` recording actual rollback time, restore time, and switch verification.
227
+ - **Expand-and-Contract Rule:** Additive changes only in release $N$; removals deferred to release $N+1$.
228
+ - **Destructive Operation Blocking:** Blocks automatic execution of `DROP`, `TRUNCATE`, database reset, or force-push.
229
+
230
+ ---
231
+
232
+ ### 2.6 Configuration Inheritance & Documented Exceptions
233
+ Stored in `.devworkspace/standards/config.json`:
234
+
235
+ ```json
236
+ {
237
+ "version": "1.0.0",
238
+ "autoDetect": true,
239
+ "enforcement": {
240
+ "security": "required",
241
+ "database": "required",
242
+ "deployment": "required",
243
+ "testing": "required",
244
+ "code-quality": "recommended",
245
+ "architecture": "recommended"
246
+ },
247
+ "disabledStandards": [],
248
+ "exceptions": [
249
+ {
250
+ "ruleId": "database.expand-and-contract",
251
+ "reason": "Initial greenfield project initialization before production deployment",
252
+ "approvedBy": "Lead Architect",
253
+ "approvedAt": "2026-11-30T10:00:00Z",
254
+ "expiresAt": "2026-12-31T23:59:59Z"
255
+ }
256
+ ]
257
+ }
258
+ ```
259
+ **Security Non-Bypassable Rule:** Critical global security rules (`security.secret-detection`, `security.dependency-audit`) cannot be bypassed by simple disable flags; they require a fully documented exception with justification, approver, and expiration date.
260
+
261
+ ---
262
+
263
+ ### 2.7 Knowledge Acquisition Workflow (`devworkspace standards add`)
264
+ Provides a structured, offline ingestion pipeline:
265
+ 1. `devworkspace standards add <file>` accepts Markdown or JSON standard definitions.
266
+ 2. Parses frontmatter or metadata.
267
+ 3. Validates against `EngineeringStandard` schema.
268
+ 4. Checks for duplicate standard IDs or conflicting requirements.
269
+ 5. Saves with status `DRAFT` or `REVIEW`.
270
+ 6. Generates recommendations for executable validator rules.
271
+ 7. Promotes to `APPROVED` only upon maintainer review (`devworkspace standards approve <id>`).
272
+
273
+ ---
274
+
275
+ ### 2.8 CLI Integration & Command Surface
276
+
277
+ Integrated directly into `devworkspace` CLI:
278
+ - `devworkspace standards list`: Lists all available standards with status, category, and applicability.
279
+ - `devworkspace standards show <id>`: Displays full requirements, guidelines, rules, and validators.
280
+ - `devworkspace standards audit`: Determines applicable standards and checks current project compliance.
281
+ - `devworkspace standards check`: Executes all applicable validators and returns PASS/WARN/FAIL findings.
282
+ - `devworkspace standards apply <id>`: Applies standard rules, creates required templates (e.g. `ROLLBACK.md`), updates configuration.
283
+ - `devworkspace standards add <path>`: Imports a new standard into the local/global library.
284
+ - `devworkspace standards update`: Synchronizes approved global standards and updates registry cache.
285
+ - `devworkspace standards report [--out <path>]`: Emits comprehensive compliance audit report in Markdown or JSON.
286
+ - `devworkspace standards validate`: Validates internal registry consistency and rule linkage.
287
+ - All commands support `--json`, `--quiet`, `--verbose`, and strict exit codes for CI/CD integration.