@hongmaple0820/scale-engine 0.40.2 → 0.44.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 (227) hide show
  1. package/README.md +30 -2
  2. package/dist/api/cli.js +43 -2
  3. package/dist/api/cli.js.map +1 -1
  4. package/dist/api/quickstart.d.ts +11 -0
  5. package/dist/api/quickstart.js +98 -1
  6. package/dist/api/quickstart.js.map +1 -1
  7. package/dist/artifact/fsmDefinitions.js +15 -2
  8. package/dist/artifact/fsmDefinitions.js.map +1 -1
  9. package/dist/artifact/types.d.ts +1 -1
  10. package/dist/artifact/types.js.map +1 -1
  11. package/dist/cache/ScanCache.d.ts +41 -0
  12. package/dist/cache/ScanCache.js +120 -0
  13. package/dist/cache/ScanCache.js.map +1 -0
  14. package/dist/capabilities/BrowserQACapability.d.ts +14 -0
  15. package/dist/capabilities/BrowserQACapability.js +94 -0
  16. package/dist/capabilities/BrowserQACapability.js.map +1 -1
  17. package/dist/cli/autofixCommands.d.ts +22 -0
  18. package/dist/cli/autofixCommands.js +32 -0
  19. package/dist/cli/autofixCommands.js.map +1 -0
  20. package/dist/cli/cortexCommands.d.ts +71 -0
  21. package/dist/cli/cortexCommands.js +335 -0
  22. package/dist/cli/cortexCommands.js.map +1 -0
  23. package/dist/cli/costCommands.d.ts +13 -0
  24. package/dist/cli/costCommands.js +48 -0
  25. package/dist/cli/costCommands.js.map +1 -0
  26. package/dist/cli/orchCommands.d.ts +43 -0
  27. package/dist/cli/orchCommands.js +135 -0
  28. package/dist/cli/orchCommands.js.map +1 -0
  29. package/dist/cli/phaseCommands.js +1 -2
  30. package/dist/cli/phaseCommands.js.map +1 -1
  31. package/dist/cli/qaCommands.d.ts +22 -0
  32. package/dist/cli/qaCommands.js +84 -0
  33. package/dist/cli/qaCommands.js.map +1 -0
  34. package/dist/cli/quickstartCommands.d.ts +17 -0
  35. package/dist/cli/quickstartCommands.js +47 -0
  36. package/dist/cli/quickstartCommands.js.map +1 -0
  37. package/dist/cli/shieldCommands.d.ts +30 -0
  38. package/dist/cli/shieldCommands.js +212 -0
  39. package/dist/cli/shieldCommands.js.map +1 -0
  40. package/dist/cli/tuiCommands.d.ts +7 -0
  41. package/dist/cli/tuiCommands.js +33 -0
  42. package/dist/cli/tuiCommands.js.map +1 -0
  43. package/dist/codegraph/CodeIntelligence.d.ts +27 -0
  44. package/dist/codegraph/CodeIntelligence.js +316 -3
  45. package/dist/codegraph/CodeIntelligence.js.map +1 -1
  46. package/dist/config/profiles.js +26 -0
  47. package/dist/config/profiles.js.map +1 -1
  48. package/dist/cortex/GovernanceMetrics.d.ts +66 -0
  49. package/dist/cortex/GovernanceMetrics.js +230 -0
  50. package/dist/cortex/GovernanceMetrics.js.map +1 -0
  51. package/dist/cortex/InstinctExtractor.d.ts +61 -0
  52. package/dist/cortex/InstinctExtractor.js +184 -0
  53. package/dist/cortex/InstinctExtractor.js.map +1 -0
  54. package/dist/cortex/InstinctStore.d.ts +54 -0
  55. package/dist/cortex/InstinctStore.js +266 -0
  56. package/dist/cortex/InstinctStore.js.map +1 -0
  57. package/dist/cortex/ReflexionEngine.d.ts +34 -0
  58. package/dist/cortex/ReflexionEngine.js +157 -0
  59. package/dist/cortex/ReflexionEngine.js.map +1 -0
  60. package/dist/cortex/SessionInjector.d.ts +44 -0
  61. package/dist/cortex/SessionInjector.js +127 -0
  62. package/dist/cortex/SessionInjector.js.map +1 -0
  63. package/dist/cortex/adapters/ClaudeAdapter.d.ts +17 -0
  64. package/dist/cortex/adapters/ClaudeAdapter.js +61 -0
  65. package/dist/cortex/adapters/ClaudeAdapter.js.map +1 -0
  66. package/dist/cortex/adapters/CodexAdapter.d.ts +10 -0
  67. package/dist/cortex/adapters/CodexAdapter.js +52 -0
  68. package/dist/cortex/adapters/CodexAdapter.js.map +1 -0
  69. package/dist/cortex/adapters/CursorAdapter.d.ts +10 -0
  70. package/dist/cortex/adapters/CursorAdapter.js +46 -0
  71. package/dist/cortex/adapters/CursorAdapter.js.map +1 -0
  72. package/dist/cortex/adapters/GeminiAdapter.d.ts +11 -0
  73. package/dist/cortex/adapters/GeminiAdapter.js +48 -0
  74. package/dist/cortex/adapters/GeminiAdapter.js.map +1 -0
  75. package/dist/dashboard/DashboardServer.d.ts +33 -13
  76. package/dist/dashboard/DashboardServer.js +314 -182
  77. package/dist/dashboard/DashboardServer.js.map +1 -1
  78. package/dist/dashboard/index.d.ts +2 -2
  79. package/dist/dashboard/index.js +1 -1
  80. package/dist/dashboard/index.js.map +1 -1
  81. package/dist/dashboard/server.d.ts +8 -22
  82. package/dist/dashboard/server.js +2 -83
  83. package/dist/dashboard/server.js.map +1 -1
  84. package/dist/eval/BenchmarkPublisher.d.ts +25 -0
  85. package/dist/eval/BenchmarkPublisher.js +27 -0
  86. package/dist/eval/BenchmarkPublisher.js.map +1 -0
  87. package/dist/guardrails/DependencyAuditor.js +10 -1
  88. package/dist/guardrails/DependencyAuditor.js.map +1 -1
  89. package/dist/index.d.ts +1 -1
  90. package/dist/index.js +1 -1
  91. package/dist/index.js.map +1 -1
  92. package/dist/orchestrator/OrchestratorDaemon.d.ts +44 -0
  93. package/dist/orchestrator/OrchestratorDaemon.js +150 -0
  94. package/dist/orchestrator/OrchestratorDaemon.js.map +1 -0
  95. package/dist/orchestrator/PolicyLoader.d.ts +80 -0
  96. package/dist/orchestrator/PolicyLoader.js +229 -0
  97. package/dist/orchestrator/PolicyLoader.js.map +1 -0
  98. package/dist/orchestrator/ReconciliationLoop.d.ts +71 -0
  99. package/dist/orchestrator/ReconciliationLoop.js +266 -0
  100. package/dist/orchestrator/ReconciliationLoop.js.map +1 -0
  101. package/dist/orchestrator/TrackerAdapter.d.ts +60 -0
  102. package/dist/orchestrator/TrackerAdapter.js +147 -0
  103. package/dist/orchestrator/TrackerAdapter.js.map +1 -0
  104. package/dist/orchestrator/WorkspaceManager.d.ts +66 -0
  105. package/dist/orchestrator/WorkspaceManager.js +257 -0
  106. package/dist/orchestrator/WorkspaceManager.js.map +1 -0
  107. package/dist/qa/BrowserDaemon.d.ts +23 -0
  108. package/dist/qa/BrowserDaemon.js +79 -0
  109. package/dist/qa/BrowserDaemon.js.map +1 -0
  110. package/dist/qa/E2ETestOrchestrator.d.ts +14 -0
  111. package/dist/qa/E2ETestOrchestrator.js +19 -0
  112. package/dist/qa/E2ETestOrchestrator.js.map +1 -0
  113. package/dist/review/CrossModelReviewer.d.ts +35 -0
  114. package/dist/review/CrossModelReviewer.js +75 -0
  115. package/dist/review/CrossModelReviewer.js.map +1 -0
  116. package/dist/review/ReviewAggregator.d.ts +13 -0
  117. package/dist/review/ReviewAggregator.js +28 -0
  118. package/dist/review/ReviewAggregator.js.map +1 -0
  119. package/dist/review/reviewCommands.d.ts +15 -0
  120. package/dist/review/reviewCommands.js +24 -0
  121. package/dist/review/reviewCommands.js.map +1 -0
  122. package/dist/routing/LocalModelProvider.d.ts +11 -0
  123. package/dist/routing/LocalModelProvider.js +21 -0
  124. package/dist/routing/LocalModelProvider.js.map +1 -0
  125. package/dist/routing/ModelRouter.d.ts +12 -0
  126. package/dist/routing/ModelRouter.js +31 -4
  127. package/dist/routing/ModelRouter.js.map +1 -1
  128. package/dist/runtime/AiOsRuntime.d.ts +1 -0
  129. package/dist/runtime/AiOsRuntime.js +15 -0
  130. package/dist/runtime/AiOsRuntime.js.map +1 -1
  131. package/dist/runtime/CostAnalyzer.d.ts +53 -0
  132. package/dist/runtime/CostAnalyzer.js +160 -0
  133. package/dist/runtime/CostAnalyzer.js.map +1 -0
  134. package/dist/runtime/CostOptimizer.d.ts +11 -0
  135. package/dist/runtime/CostOptimizer.js +21 -0
  136. package/dist/runtime/CostOptimizer.js.map +1 -0
  137. package/dist/shield/PolicyCompiler.d.ts +70 -0
  138. package/dist/shield/PolicyCompiler.js +540 -0
  139. package/dist/shield/PolicyCompiler.js.map +1 -0
  140. package/dist/shield/ProtectedPaths.d.ts +39 -0
  141. package/dist/shield/ProtectedPaths.js +179 -0
  142. package/dist/shield/ProtectedPaths.js.map +1 -0
  143. package/dist/shield/ShieldProtocol.d.ts +50 -0
  144. package/dist/shield/ShieldProtocol.js +103 -0
  145. package/dist/shield/ShieldProtocol.js.map +1 -0
  146. package/dist/skills/SkillMdStandard.d.ts +33 -0
  147. package/dist/skills/SkillMdStandard.js +88 -0
  148. package/dist/skills/SkillMdStandard.js.map +1 -0
  149. package/dist/skills/SkillRegistry.d.ts +9 -1
  150. package/dist/skills/SkillRegistry.js +20 -0
  151. package/dist/skills/SkillRegistry.js.map +1 -1
  152. package/dist/skills/interop/GStackInterop.d.ts +15 -0
  153. package/dist/skills/interop/GStackInterop.js +34 -0
  154. package/dist/skills/interop/GStackInterop.js.map +1 -0
  155. package/dist/skills/interop/OMCInterop.d.ts +15 -0
  156. package/dist/skills/interop/OMCInterop.js +34 -0
  157. package/dist/skills/interop/OMCInterop.js.map +1 -0
  158. package/dist/topology/DomainMapper.d.ts +23 -0
  159. package/dist/topology/DomainMapper.js +179 -0
  160. package/dist/topology/DomainMapper.js.map +1 -0
  161. package/dist/topology/LayerClassifier.d.ts +8 -0
  162. package/dist/topology/LayerClassifier.js +109 -0
  163. package/dist/topology/LayerClassifier.js.map +1 -0
  164. package/dist/topology/TourGenerator.d.ts +18 -0
  165. package/dist/topology/TourGenerator.js +120 -0
  166. package/dist/topology/TourGenerator.js.map +1 -0
  167. package/dist/topology/index.d.ts +3 -0
  168. package/dist/topology/index.js +4 -0
  169. package/dist/topology/index.js.map +1 -0
  170. package/dist/tui/TuiDashboard.d.ts +3 -0
  171. package/dist/tui/TuiDashboard.js +120 -0
  172. package/dist/tui/TuiDashboard.js.map +1 -0
  173. package/dist/workflow/GateCatalog.d.ts +2 -0
  174. package/dist/workflow/GateCatalog.js +59 -3
  175. package/dist/workflow/GateCatalog.js.map +1 -1
  176. package/dist/workflow/GovernanceTemplatePacks.d.ts +1 -1
  177. package/dist/workflow/GovernanceTemplatePacks.js +15 -0
  178. package/dist/workflow/GovernanceTemplatePacks.js.map +1 -1
  179. package/dist/workflow/TddLoop.d.ts +2 -0
  180. package/dist/workflow/TddLoop.js +2 -0
  181. package/dist/workflow/TddLoop.js.map +1 -1
  182. package/dist/workflow/UpgradeManager.d.ts +10 -1
  183. package/dist/workflow/UpgradeManager.js +55 -0
  184. package/dist/workflow/UpgradeManager.js.map +1 -1
  185. package/dist/workflow/VerificationProfile.d.ts +8 -0
  186. package/dist/workflow/VerificationProfile.js +61 -0
  187. package/dist/workflow/VerificationProfile.js.map +1 -1
  188. package/dist/workflow/VerificationSchema.d.ts +46 -0
  189. package/dist/workflow/VerificationSchema.js +97 -0
  190. package/dist/workflow/VerificationSchema.js.map +1 -0
  191. package/dist/workflow/autofix/AutoFixEngine.d.ts +37 -0
  192. package/dist/workflow/autofix/AutoFixEngine.js +169 -0
  193. package/dist/workflow/autofix/AutoFixEngine.js.map +1 -0
  194. package/dist/workflow/execution/RalphEngine.d.ts +18 -0
  195. package/dist/workflow/execution/RalphEngine.js +22 -0
  196. package/dist/workflow/execution/RalphEngine.js.map +1 -1
  197. package/dist/workflow/gates/EnhancedGates.d.ts +74 -0
  198. package/dist/workflow/gates/EnhancedGates.js +653 -0
  199. package/dist/workflow/gates/EnhancedGates.js.map +1 -0
  200. package/dist/workflow/gates/GateSystem.d.ts +3 -0
  201. package/dist/workflow/gates/GateSystem.js +94 -1
  202. package/dist/workflow/gates/GateSystem.js.map +1 -1
  203. package/dist/workflow/types.d.ts +1 -1
  204. package/docs/README.md +3 -0
  205. package/docs/guides/DEVELOPMENT_WORKFLOW.md +28 -9
  206. package/docs/guides/GETTING_STARTED.md +19 -0
  207. package/docs/guides/MIGRATION.md +119 -0
  208. package/docs/workflow/GATES_AND_SCORE.md +34 -1
  209. package/docs/workflow/README.md +58 -10
  210. package/package.json +7 -17
  211. package/docs/ACTIVE_SECURITY_VISUAL_GATES.md +0 -87
  212. package/docs/AI_ENGINEERING_OS_POSITIONING.md +0 -607
  213. package/docs/BACKGROUND_HUNTER.md +0 -62
  214. package/docs/CODE_INTELLIGENCE.md +0 -180
  215. package/docs/CONTEXT_BUDGET.md +0 -165
  216. package/docs/DEPENDENCY_AUDIT.md +0 -118
  217. package/docs/EVOLUTION_SHADOW_MODE.md +0 -63
  218. package/docs/GITLAB_FLOW.md +0 -125
  219. package/docs/GOVERNANCE_DASHBOARD.md +0 -92
  220. package/docs/MEMORY_BRAIN.md +0 -104
  221. package/docs/MEMORY_FABRIC.md +0 -161
  222. package/docs/RESOURCE_GOVERNANCE.md +0 -92
  223. package/docs/RUNTIME_EVIDENCE.md +0 -101
  224. package/docs/WORKFLOW_EVAL.md +0 -151
  225. package/image/wechat-public.jpg +0 -0
  226. package/image/wxPay.jpg +0 -0
  227. package/image/zfb.jpg +0 -0
@@ -1,180 +0,0 @@
1
- # Code Intelligence
2
-
3
- SCALE uses an adapter-first code intelligence layer. It can consume the upstream [colbymchenry/codegraph](https://github.com/colbymchenry/codegraph) CLI when it is installed and the project has a local `.codegraph/` index, read graph artifacts such as Graphify outputs, and fall back to a scoped internal source scan when no provider is available.
4
-
5
- The goal is not to replace IDE indexing. The goal is to make exploration measurable:
6
-
7
- - which provider answered the query
8
- - whether fallback was used
9
- - which files are likely relevant
10
- - how many file reads were avoided
11
- - what confidence the result has
12
-
13
- ## Quick Start
14
-
15
- Optional upstream install:
16
-
17
- ```bash
18
- npx @colbymchenry/codegraph
19
- # or
20
- npm i -g @colbymchenry/codegraph
21
- codegraph init -i
22
- ```
23
-
24
- Governed SCALE setup:
25
-
26
- ```bash
27
- scale setup --pack knowledge
28
- scale codegraph status --json
29
- ```
30
-
31
- For Graphify, prefer isolated tool installation:
32
-
33
- ```bash
34
- uv tool install graphify
35
- graphify install --platform codex
36
- graphify query "auth service" --graph graphify-out/graph.json
37
- ```
38
-
39
- Run a real large-project rehearsal before treating Graphify as an operational knowledge provider:
40
-
41
- ```bash
42
- npm run smoke:graphify -- --large-project /path/to/large-project
43
- node scripts/workflow/provider-rehearsal.mjs --skip-gbrain --require-graphify --large-project /path/to/large-project
44
- ```
45
-
46
- The rehearsal executes `graphify update <project> --no-cluster` by default so graph generation stays AST/Python based and does not call a model. It locates the generated `graph.json`, parses graph stats, and runs `graphify query`. Use `--semantic-extract` only when semantic LLM extraction is explicitly allowed. Do not commit generated `graphify-out/` artifacts by default; commit only reviewed knowledge summaries, docs, or rules derived from the graph.
47
-
48
- Create the optional provider configuration:
49
-
50
- ```bash
51
- scale codegraph init
52
- ```
53
-
54
- Inspect provider availability:
55
-
56
- ```bash
57
- scale codegraph status
58
- scale codegraph status --json
59
- scale tool doctor --tools codegraph,graphify --json
60
- ```
61
-
62
- Query code intelligence:
63
-
64
- ```bash
65
- scale codegraph query "UserService.create"
66
- scale codegraph impact --symbol UserService.create
67
- scale codegraph context --symbol UserService.create --budget 2000
68
- scale codegraph roi --symbol UserService.create
69
- ```
70
-
71
- ## Configuration
72
-
73
- The configuration file lives at:
74
-
75
- ```text
76
- .scale/code-intelligence.json
77
- ```
78
-
79
- Default shape:
80
-
81
- ```json
82
- {
83
- "version": "1.0",
84
- "providers": [
85
- {
86
- "id": "codegraph",
87
- "type": "external-cli",
88
- "enabled": true,
89
- "command": "codegraph",
90
- "capabilities": ["symbols", "callers", "callees", "impact", "context", "summary", "module-map"],
91
- "source": "https://github.com/colbymchenry/codegraph",
92
- "installHint": "npx @colbymchenry/codegraph or npm i -g @colbymchenry/codegraph",
93
- "projectInitHint": "codegraph init -i",
94
- "serveCommand": "codegraph serve --mcp"
95
- },
96
- {
97
- "id": "graphify",
98
- "type": "artifact",
99
- "enabled": true,
100
- "manifest": "graphify-out/graph.json",
101
- "capabilities": ["symbols", "callers", "callees", "impact", "context", "summary", "module-map"],
102
- "source": "https://github.com/safishamsi/graphify",
103
- "installHint": "uv tool install graphify && graphify install --platform codex"
104
- }
105
- ],
106
- "fallback": {
107
- "enabled": true,
108
- "tools": ["internal-scan", "rg", "read"]
109
- }
110
- }
111
- ```
112
-
113
- ## Provider Types
114
-
115
- | Type | Use |
116
- | --- | --- |
117
- | `external-cli` | Detects an installed external code graph command. For `codegraph`, SCALE consumes the official JSON output from `codegraph query --json` and `codegraph context --format json` when `.codegraph/` exists. |
118
- | `artifact` | Reads a local graph manifest or report file. JSON manifests can provide symbol impact data. |
119
- | fallback | Uses a bounded internal source scan when providers are unavailable or return no hits. |
120
-
121
- ## JSON Artifact Provider
122
-
123
- Artifact providers can point at a JSON manifest:
124
-
125
- ```json
126
- {
127
- "symbols": [
128
- {
129
- "name": "UserService.create",
130
- "file": "src/user.ts",
131
- "callers": ["src/api.ts"],
132
- "callees": ["src/db.ts"]
133
- }
134
- ],
135
- "files": [
136
- {
137
- "path": "src/user.ts",
138
- "symbols": ["UserService.create"]
139
- }
140
- ]
141
- }
142
- ```
143
-
144
- This allows SCALE to answer impact queries without reading the whole repository.
145
-
146
- ## ROI Metrics
147
-
148
- Code intelligence reports include:
149
-
150
- | Metric | Meaning |
151
- | --- | --- |
152
- | `graphHits` | Number of hits from graph providers. |
153
- | `fallbackCount` | Whether fallback was needed. |
154
- | `baselineFileReads` | Estimated broad exploration file reads. |
155
- | `recommendedFileReads` | Scoped file reads recommended by the query result. |
156
- | `fileReadsSaved` | Estimated avoided reads. |
157
- | `toolCallsSaved` | Estimated avoided exploration tool calls. |
158
-
159
- These numbers are deliberately conservative. They are a local signal for whether graph-assisted exploration is worth keeping default for a task class.
160
-
161
- ## Governance ROI
162
-
163
- `scale governance roi` can include code intelligence:
164
-
165
- ```bash
166
- scale governance roi --symbol UserService.create
167
- scale governance roi --code-query createUser
168
- ```
169
-
170
- When a graph provider answers, the module is reported as measured evidence. When fallback is used, the module is reported as estimated and needs more evidence before becoming a stronger default.
171
-
172
- ## Policy
173
-
174
- - SCALE must run when no code graph provider is installed.
175
- - Missing providers must produce explicit fallback, not silent success.
176
- - External tools are installed only through explicit user intent such as `scale setup --pack knowledge --yes` or `scale bootstrap deps --pack knowledge --apply`.
177
- - When CodeGraph is installed and the project is initialized, SCALE should prefer the upstream JSON query/context surfaces before falling back to raw file scans.
178
- - Graphify is treated as an artifact provider. CLI installation is not enough; `graphify-out/graph.json` must exist before graph-backed knowledge recall can use it.
179
- - Source files are read only through a bounded fallback scan.
180
- - Large generated graph outputs should stay outside default prompt context; use summaries and file paths.
@@ -1,165 +0,0 @@
1
- # Context Budget And Progressive Governance
2
-
3
- Status: implemented baseline
4
- Since: v0.20 development branch
5
-
6
- This feature keeps SCALE from becoming its own context pollution source. It separates always-loaded rules from on-demand documents, runtime evidence, historical archives, and generated artifacts.
7
-
8
- ## Commands
9
-
10
- Report token cost by context category:
11
-
12
- ```bash
13
- scale context budget --json
14
- ```
15
-
16
- Include provider-specific prompt cache policy:
17
-
18
- ```bash
19
- scale context budget --provider anthropic --json
20
- scale context budget --provider openai --json
21
- ```
22
-
23
- Write the report to `.scale/context-budget.json`:
24
-
25
- ```bash
26
- scale context budget --write
27
- ```
28
-
29
- Check thresholds:
30
-
31
- ```bash
32
- scale context doctor --max-always 1500 --max-task 4000
33
- ```
34
-
35
- Build a lazy-loaded task context pack:
36
-
37
- ```bash
38
- scale context pack \
39
- --task "Review frontend route with browser evidence" \
40
- --level L \
41
- --files src/routes/upload.tsx \
42
- --budget 4000 \
43
- --json
44
- ```
45
-
46
- Build the unified AI OS runtime plan that embeds the context pack with memory, skill routing, evaluator intelligence, tool strategy, adaptive workflow, and ROI:
47
-
48
- ```bash
49
- scale ai-os plan \
50
- --task-id TASK-123 \
51
- --task "Review frontend route with browser evidence" \
52
- --level L \
53
- --files src/routes/upload.tsx \
54
- --budget 4000 \
55
- --json
56
- ```
57
-
58
- The context pack now uses the baseline Context Compiler. Each candidate section is scored by category, task/file relevance, risk level, and budget fit. The JSON output includes compiler metadata so callers can explain why a section was loaded or omitted:
59
-
60
- ```json
61
- {
62
- "compiler": {
63
- "strategy": "relevance-budget-v1",
64
- "budget": 4000,
65
- "totalCandidateTokens": 6200,
66
- "estimatedTokenSavings": 2200,
67
- "ranking": [
68
- {
69
- "id": "runtime-evidence",
70
- "included": true,
71
- "score": 292,
72
- "matchedSignals": ["evidence", "high-risk-evidence"],
73
- "reason": "Evidence is needed for completion and verification claims."
74
- }
75
- ]
76
- }
77
- }
78
- ```
79
-
80
- Evaluate progressive governance mode:
81
-
82
- ```bash
83
- scale governance mode \
84
- --task "Change auth permissions and database migration" \
85
- --files src/auth/user.ts,migrations/001.sql \
86
- --requested-mode minimal \
87
- --json
88
- ```
89
-
90
- Report governance benefit and overhead:
91
-
92
- ```bash
93
- scale governance roi \
94
- --task-id TASK-123 \
95
- --task "Review frontend route with browser evidence" \
96
- --files src/routes/upload.tsx \
97
- --json
98
- ```
99
-
100
- ## Categories
101
-
102
- | Category | Meaning | Loading Policy |
103
- | --- | --- | --- |
104
- | `always` | Tiny entrypoint rules and source-of-truth governance config | Keep under strict token budget |
105
- | `on-demand` | Domain docs and governance guides | Load only when task trigger matches |
106
- | `evidence` | Runtime evidence and task artifacts | Summarize and reference by path |
107
- | `archive` | Historical plans and old roadmap context | Do not load unless explicitly requested |
108
- | `generated` | HTML reports, screenshots, graph outputs, generated artifacts | Keep manifest-only by default |
109
-
110
- ## Prompt Cache Policy
111
-
112
- V2.0 adds a cache policy layer for stable context. The policy is intentionally conservative:
113
-
114
- - `always` is cache-eligible by default because it contains stable entrypoint rules and governance source-of-truth config.
115
- - `on-demand` is not cache-eligible by default because it changes with task intent and can break stable prefix reuse.
116
- - `evidence`, `archive`, and `generated` are never cache-eligible by default.
117
- - Unsupported providers still write usage evidence; they do not pretend to support prompt caching.
118
-
119
- Provider behavior:
120
-
121
- | Provider | Strategy | Usage fields |
122
- | --- | --- | --- |
123
- | Anthropic | `anthropic-ephemeral` | `cache_creation_input_tokens`, `cache_read_input_tokens` |
124
- | OpenAI | `openai-automatic` | `prompt_tokens_details.cached_tokens` |
125
- | Other | `usage-ledger-only` | normal input/output usage only |
126
-
127
- The cache policy does not live in `ModelRouter`. `ModelRouter` selects a model; provider request builders or adapters apply provider-specific cache controls.
128
-
129
- To replace estimates with real usage evidence, write provider usage into the ledger and audit it directly:
130
-
131
- ```bash
132
- scale token record \
133
- --provider anthropic \
134
- --usage-json '{"usage":{"input_tokens":1000,"output_tokens":200,"cache_read_input_tokens":500}}'
135
-
136
- scale token report --day 2026-05-23 --json
137
- ```
138
-
139
- ## Progressive Governance
140
-
141
- SCALE now has a baseline risk classifier. It keeps low-risk documentation work in `minimal` mode and escalates risky tasks to `standard`, `expanded`, or `critical`.
142
-
143
- Examples:
144
-
145
- | Signal | Mode |
146
- | --- | --- |
147
- | README typo | `minimal` |
148
- | normal implementation task | `standard` |
149
- | UI, browser, E2E, public interface, or cross-module work | `expanded` |
150
- | auth, permission, secret, database, migration, production config, release, or destructive operation | `critical` |
151
-
152
- This is not a replacement for verification. It only decides which governance behavior should activate.
153
-
154
- ## Governance ROI
155
-
156
- `scale governance roi` reports both benefit and overhead. In v0.27.0, `scale ai-os plan` also attaches ROI modules for:
157
-
158
- - `context-budget`
159
- - `context-compiler`
160
- - `memory-provider-runtime`
161
- - `skill-routing-engine`
162
- - `progressive-governance`
163
-
164
- Early ROI is still estimated from context budget, compiler savings, recall count, skill evidence steps, and risk signals. Later versions should replace estimates with measured eval data such as file reads saved, tool calls saved, fix iterations reduced, and human corrections avoided.
165
-
@@ -1,118 +0,0 @@
1
- # Dependency Audit
2
-
3
- Dependency Audit is the G7 dependency sub-gate for SCALE Engine.
4
- It adds supply-chain checks without introducing a separate gate number such as `G6.8`.
5
-
6
- ## Scope
7
-
8
- The auditor is intentionally bounded:
9
-
10
- - reads `package-lock.json`
11
- - audits direct dependencies by default
12
- - supports `--changed-packages` for lockfile-diff workflows
13
- - scans only selected package roots under `node_modules`
14
- - caps package count and files per package
15
- - does not contact the registry by default
16
- - does not run install scripts
17
-
18
- This keeps local verification usable while still catching high-risk dependency behavior.
19
-
20
- ## Commands
21
-
22
- ```bash
23
- scale dependency audit
24
- scale dependency audit --json
25
- scale dependency audit --mode strict
26
- scale dependency audit --changed-packages left-pad,@scope/tool --json
27
- ```
28
-
29
- The command exits non-zero when the active mode has blocking findings.
30
-
31
- ## Verification Command Safety
32
-
33
- SCALE verification commands are security-sensitive because they are often run in CI.
34
- The core verification paths (`verify-task`, phase verification, workflow eval attempts, and gate commands) execute configured commands without shell expansion by default.
35
-
36
- Allowed by default:
37
-
38
- ```bash
39
- npm run build
40
- npm test -- --runInBand
41
- node scripts/check.js --changed
42
- ```
43
-
44
- Blocked by default:
45
-
46
- ```bash
47
- npm test && curl https://example.com
48
- node scripts/check.js | tee out.txt
49
- ```
50
-
51
- Shell metacharacters such as `&&`, `|`, `;`, `<`, `>`, backticks, and unquoted `$` are rejected before execution. Use package scripts or checked-in helper scripts for composed commands. `SCALE_ALLOW_SHELL_COMMANDS=1` re-enables shell execution only for trusted local runs and must not be enabled for untrusted PR or user-controlled CI inputs.
52
-
53
- ## G7 Integration
54
-
55
- `SecurityGate` now emits two first-class evidence sources:
56
-
57
- - `built-in-security-scan`: source code security scan
58
- - `dependency-audit`: dependency supply-chain scan
59
-
60
- Both remain under `G7 Security`.
61
-
62
- ## Policy
63
-
64
- Policy lives at `.scale/security/dependency-policy.json`:
65
-
66
- ```json
67
- {
68
- "version": 1,
69
- "mode": "compatibility",
70
- "maxPackages": 50,
71
- "maxPackageFiles": 25,
72
- "allowPackages": [],
73
- "baselineFindings": []
74
- }
75
- ```
76
-
77
- Modes:
78
-
79
- - `compatibility`: blocks `CRITICAL`
80
- - `strict`: blocks `CRITICAL` and `HIGH`
81
- - `offline`: keeps local-only behavior; current offline findings follow compatibility blocking
82
-
83
- Use `baselineFindings` for accepted legacy dependency risk:
84
-
85
- ```json
86
- {
87
- "baselineFindings": [
88
- {
89
- "packageName": "legacy-tool",
90
- "version": "1.2.3",
91
- "ruleId": "dependency.install-script",
92
- "reason": "Pinned and reviewed during migration window."
93
- }
94
- ]
95
- }
96
- ```
97
-
98
- Prefer a baseline over `allowPackages` when only one finding is accepted. `allowPackages` suppresses all findings for that package.
99
-
100
- ## Current Findings
101
-
102
- The first implementation detects:
103
-
104
- - install lifecycle scripts
105
- - executable bin scripts
106
- - deprecated packages from lockfile metadata
107
- - built-in ownership/provenance watchlist matches
108
- - dynamic code execution: `eval`, `new Function`
109
- - shell execution patterns
110
- - suspicious network access patterns
111
-
112
- The built-in ownership/provenance watchlist currently blocks exact versions that were flagged by external package behavior analysis:
113
-
114
- - `content-type@2.0.0`
115
- - `type-is@2.1.0`
116
- - `type-js@2.1.0` (kept as a defensive alias for reports that use this package name)
117
-
118
- Future network-backed checks can add npm registry metadata and `npm audit --json` ingestion, but they should stay optional and evidence-backed.
@@ -1,63 +0,0 @@
1
- # Evolution Shadow Mode
2
-
3
- SCALE V2 keeps self-evolution useful without letting one-off failures become hard blockers too early.
4
-
5
- ## Flow
6
-
7
- ```text
8
- Gate Failure
9
- -> Defect
10
- -> Lesson
11
- -> Proposed Rule
12
- -> Shadow Rule
13
- -> Candidate Hook
14
- -> Approved Blocking Hook
15
- ```
16
-
17
- ## Gate Failure To Defect
18
-
19
- `GateSystem` emits `gate.failed` for failed gate results. `AutoDefectCreator` tracks consecutive failures per session and gate stage.
20
-
21
- Default behavior:
22
-
23
- - three consecutive failures create one `Defect`
24
- - a passing `gate.executed` event resets the streak
25
- - defect payload uses `rootCauseCategory=gate_failure`
26
- - the original blockers, evidence, evidence record id, stage, and streak count are stored in defect context
27
-
28
- This is evidence capture only. It does not change source code or generate a hook.
29
-
30
- ## Rule Maturity
31
-
32
- New rules start in `shadow` mode. Shadow rules can record hits, but they do not block development.
33
-
34
- Promotion requires:
35
-
36
- - shadow hits >= 10
37
- - at least one defect evidence id
38
- - rollback method present
39
- - false positive rate within threshold
40
- - explicit approval before a blocking hook is allowed
41
-
42
- `RuleMaturity` exposes:
43
-
44
- - `createShadowRuleMaturity`
45
- - `recordShadowHit`
46
- - `evaluateRulePromotion`
47
- - `approveRuleMaturity`
48
-
49
- ## Hook Boundary
50
-
51
- `HookGenerator` still requires `rule.approved === true`.
52
-
53
- For V2 rules that carry maturity metadata, it also requires:
54
-
55
- ```text
56
- rule.maturity.stage === "approved-blocking"
57
- ```
58
-
59
- That means proposed or shadow rules can be observed and improved, but cannot become blocking hooks until explicitly promoted.
60
-
61
- ## Current Scope
62
-
63
- This release slice wires the core library path and gate events. CLI approval commands and persistent rule-maturity storage can be added later without changing the safety model.
@@ -1,125 +0,0 @@
1
- # GitLab Flow Branch and Worktree Policy
2
-
3
- SCALE Engine uses a GitLab Flow variant for this repository:
4
-
5
- ```text
6
- feat/* / fix/* / chore/* / docs/* / codex/*
7
- -> dev
8
- -> master
9
- -> vX.Y.Z tag
10
- -> npm publish
11
-
12
- hotfix:
13
- fix forward on dev first when possible
14
- -> cherry-pick to hotfix/*
15
- -> master
16
- -> vX.Y.Z tag
17
- -> sync master back to dev
18
-
19
- selective release, only when dev contains work that must not ship:
20
- master
21
- -> release/vX.Y.Z
22
- -> cherry-pick selected commits
23
- -> master
24
- -> vX.Y.Z tag
25
- -> sync master back to dev
26
- ```
27
-
28
- ## Branch Roles
29
-
30
- | Branch | Role | Rule |
31
- | --- | --- | --- |
32
- | `dev` | Integration and test branch | Merge reviewed short branches here. Do not create direct governed commits on `dev`. |
33
- | `master` | Production branch | Only verified release/hotfix results land here. Publish from user-created `vX.Y.Z` tags on `master`. |
34
- | `feat/*`, `feature/*` | Feature branches | Start from current `dev`, merge back to `dev`, then delete. |
35
- | `fix/*` | Normal bug fix branches | Start from current `dev`, merge back to `dev`, then delete. |
36
- | `chore/*`, `docs/*`, `codex/*` | Maintenance branches | Short-lived work branches that merge back to `dev`. |
37
- | `hotfix/*` | Production patch branches | Use only for production fixes. Fix forward to `dev` first when possible, then cherry-pick to hotfix/master. |
38
- | `release/*` | Selective release branch | Use only when `dev` contains work that must not ship. Start from `master` and cherry-pick the release list. |
39
-
40
- ## Required Checks
41
-
42
- Run the release-grade verification set before merging to `master` or tagging:
43
-
44
- ```bash
45
- npm run build
46
- npx vitest run
47
- git diff --check
48
- npm pack --dry-run
49
- ```
50
-
51
- Every merge request should run the relevant build/lint/test checks before review is accepted. Do not wait until `master` to discover broken tests.
52
-
53
- ## Merge and Conflict Rules
54
-
55
- - Public branches are not rebased: `dev`, `master`, `release/*`, and `hotfix/*` keep realistic history.
56
- - Personal short branches may be rebased before merge, but only with `--force-with-lease` and only before review is accepted.
57
- - Prefer squash merge from short branches into `dev` when one logical change should be easy to revert.
58
- - Resolve conflicts on the source branch, rerun verification, then merge. Do not resolve release conflicts directly on `master`.
59
- - Fix bugs forward first: land the fix on `dev` when possible, then cherry-pick the same commit to `hotfix/*` or the selected patch release branch.
60
- - Commit messages should explain intent and why the chosen path was selected when the decision is not obvious.
61
-
62
- ## Ship Gate Rules
63
-
64
- `scale ship <task-id>` now enforces the branch lifecycle:
65
-
66
- - blocked on `dev`, `master`, `main`, and detached HEAD
67
- - allowed on configured short branches such as `feat/*`, `fix/*`, `chore/*`, `docs/*`, `codex/*`, `release/*`, and `hotfix/*`
68
- - still requires verification evidence, passing review evidence, and reviewed-file-only staging
69
- - still blocks dirty or unsafe child repositories in MOE/submodule workspaces
70
-
71
- Use:
72
-
73
- ```bash
74
- scale workspace status --summary
75
- scale workspace finish --summary
76
- scale workspace finish --json
77
- ```
78
-
79
- The report includes branch role, whether governed shipping is allowed, and cleanup blockers.
80
-
81
- ## Worktree Lifecycle
82
-
83
- Temporary agent worktrees are safe to remove only when all of these are true:
84
-
85
- - root worktree is clean
86
- - child repositories are clean and pushed when required
87
- - the temporary branch has no unpushed commits
88
- - a branch with no upstream is already merged into `dev`/`master`, or it contains no unique work
89
-
90
- Cleanup remains dry-run by default:
91
-
92
- ```bash
93
- scale workspace cleanup --dir <temporary-worktree> --dry-run --json
94
- scale workspace cleanup --dir <temporary-worktree> --apply --confirm <branch-or-head> --json
95
- ```
96
-
97
- If cleanup is blocked, push the branch, merge it, cherry-pick it into the selected release, or explicitly discard it before removing the worktree.
98
-
99
- ## Repository Bootstrap
100
-
101
- This repository currently treats `dev` as the integration branch and `master` as production. If `dev` falls behind `master` and has no unique commits, fast-forward `dev` to `master` before starting new feature work:
102
-
103
- ```bash
104
- git fetch --all --prune
105
- git switch dev
106
- git merge --ff-only master
107
- git push origin dev
108
- git push github dev
109
- ```
110
-
111
- After that, normal work should start from `dev`:
112
-
113
- ```bash
114
- git switch dev
115
- git pull --ff-only origin dev
116
- git switch -c feat/<short-name>
117
- ```
118
-
119
- Before creating a normal release from `dev`, inspect the release delta:
120
-
121
- ```bash
122
- git log --oneline master..dev
123
- ```
124
-
125
- If every listed commit is intended for the next production release, merge `dev` through the normal release path. If any commit must be excluded, create `release/vX.Y.Z` from `master` and cherry-pick only the approved release list.