@hongmaple0820/scale-engine 0.25.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -15
- package/README.en.md +384 -346
- package/README.md +564 -529
- package/dist/adapters/AiderAdapter.js +52 -52
- package/dist/adapters/AntigravityAdapter.d.ts +4 -0
- package/dist/adapters/AntigravityAdapter.js +21 -0
- package/dist/adapters/AntigravityAdapter.js.map +1 -0
- package/dist/adapters/ClaudeCodeAdapter.d.ts +4 -1
- package/dist/adapters/ClaudeCodeAdapter.js +34 -34
- package/dist/adapters/ClaudeCodeAdapter.js.map +1 -1
- package/dist/adapters/ClineAdapter.d.ts +4 -0
- package/dist/adapters/ClineAdapter.js +20 -0
- package/dist/adapters/ClineAdapter.js.map +1 -0
- package/dist/adapters/CodexAdapter.js +28 -28
- package/dist/adapters/CursorAdapter.js +26 -26
- package/dist/adapters/DeepSeekTuiAdapter.js +97 -97
- package/dist/adapters/DoubaoAdapter.js +33 -33
- package/dist/adapters/GeminiAdapter.js +26 -26
- package/dist/adapters/GenericProjectAgentAdapter.d.ts +29 -0
- package/dist/adapters/GenericProjectAgentAdapter.js +204 -0
- package/dist/adapters/GenericProjectAgentAdapter.js.map +1 -0
- package/dist/adapters/HermesAdapter.js +26 -26
- package/dist/adapters/JCodeAdapter.d.ts +4 -0
- package/dist/adapters/JCodeAdapter.js +19 -0
- package/dist/adapters/JCodeAdapter.js.map +1 -0
- package/dist/adapters/KiloCodeAdapter.d.ts +4 -0
- package/dist/adapters/KiloCodeAdapter.js +20 -0
- package/dist/adapters/KiloCodeAdapter.js.map +1 -0
- package/dist/adapters/KimiAdapter.js +32 -32
- package/dist/adapters/KiroAdapter.js +26 -26
- package/dist/adapters/OpenClawAdapter.js +26 -26
- package/dist/adapters/OpenCodeAdapter.js +26 -26
- package/dist/adapters/QCoderAdapter.js +26 -26
- package/dist/adapters/QoderAdapter.d.ts +4 -0
- package/dist/adapters/QoderAdapter.js +21 -0
- package/dist/adapters/QoderAdapter.js.map +1 -0
- package/dist/adapters/TraeAdapter.js +26 -26
- package/dist/adapters/VSCAdapter.js +26 -26
- package/dist/adapters/WindsurfAdapter.js +32 -32
- package/dist/adapters/WorkBuddyAdapter.js +26 -26
- package/dist/adapters/index.d.ts +5 -0
- package/dist/adapters/index.js +15 -0
- package/dist/adapters/index.js.map +1 -1
- package/dist/api/cli.js +190 -56
- package/dist/api/cli.js.map +1 -1
- package/dist/api/doctor.js +10 -3
- package/dist/api/doctor.js.map +1 -1
- package/dist/api/quickstart.js +7 -1
- package/dist/api/quickstart.js.map +1 -1
- package/dist/artifact/sqliteStore.js +89 -89
- package/dist/artifact/types.d.ts +1 -1
- package/dist/cli/phaseCommands.js +53 -53
- package/dist/cli/phaseCommands.js.map +1 -1
- package/dist/context/AntiPatternRegistry.js +20 -20
- package/dist/context/ContextBudget.d.ts +14 -0
- package/dist/context/ContextBudget.js +50 -14
- package/dist/context/ContextBudget.js.map +1 -1
- package/dist/context/ContextBuilder.js +155 -155
- package/dist/context/ContextCompiler.d.ts +34 -0
- package/dist/context/ContextCompiler.js +120 -0
- package/dist/context/ContextCompiler.js.map +1 -0
- package/dist/eval/WorkflowEval.js +4 -6
- package/dist/eval/WorkflowEval.js.map +1 -1
- package/dist/evolution/EvolutionEngine.js +31 -31
- package/dist/evolution/EvolutionEvaluator.d.ts +2 -0
- package/dist/evolution/EvolutionEvaluator.js +7 -1
- package/dist/evolution/EvolutionEvaluator.js.map +1 -1
- package/dist/fsm/FSMAgentBridge.js +11 -11
- package/dist/governance/GovernanceRoi.d.ts +6 -1
- package/dist/governance/GovernanceRoi.js +32 -0
- package/dist/governance/GovernanceRoi.js.map +1 -1
- package/dist/guardrails/DependencyAuditor.js +38 -0
- package/dist/guardrails/DependencyAuditor.js.map +1 -1
- package/dist/hooks/HookGeneratorEnhanced.js +218 -218
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/knowledge/SQLiteKnowledgeBase.js +28 -28
- package/dist/memory/MemoryBrain.js +52 -52
- package/dist/output/GovernanceDashboard.js +44 -44
- package/dist/output/HTMLArtifactLayer.js +31 -31
- package/dist/prompts/VibeTemplateGallery.js +121 -121
- package/dist/runtime/AiOsRuntime.d.ts +53 -0
- package/dist/runtime/AiOsRuntime.js +142 -0
- package/dist/runtime/AiOsRuntime.js.map +1 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/skills/SkillDiscovery.js +12 -1
- package/dist/skills/SkillDiscovery.js.map +1 -1
- package/dist/skills/routing/SkillPlanner.js +128 -40
- package/dist/skills/routing/SkillPlanner.js.map +1 -1
- package/dist/skills/routing/SkillRoutingTypes.d.ts +17 -0
- package/dist/tools/SafeCommandRunner.d.ts +16 -0
- package/dist/tools/SafeCommandRunner.js +83 -0
- package/dist/tools/SafeCommandRunner.js.map +1 -0
- package/dist/workflow/EngineeringStandards.js +62 -62
- package/dist/workflow/GovernanceTemplatePacks.d.ts +1 -1
- package/dist/workflow/GovernanceTemplatePacks.js +1990 -162
- package/dist/workflow/GovernanceTemplatePacks.js.map +1 -1
- package/dist/workflow/GovernanceTemplates.d.ts +2 -0
- package/dist/workflow/GovernanceTemplates.js +1012 -1001
- package/dist/workflow/GovernanceTemplates.js.map +1 -1
- package/dist/workflow/ResourceGovernance.js +16 -16
- package/dist/workflow/TaskArtifactScaffolder.js +10 -10
- package/dist/workflow/UpgradeManager.d.ts +3 -2
- package/dist/workflow/UpgradeManager.js +134 -49
- package/dist/workflow/UpgradeManager.js.map +1 -1
- package/dist/workflow/WorkspaceTopology.js +18 -15
- package/dist/workflow/WorkspaceTopology.js.map +1 -1
- package/dist/workflow/gates/GateSystem.js +3 -9
- package/dist/workflow/gates/GateSystem.js.map +1 -1
- package/docs/ACTIVE_SECURITY_VISUAL_GATES.md +87 -87
- package/docs/AI_ENGINEERING_OS_POSITIONING.md +462 -0
- package/docs/BACKGROUND_HUNTER.md +62 -62
- package/docs/CODE_INTELLIGENCE.md +138 -138
- package/docs/CONTEXT_BUDGET.md +155 -113
- package/docs/DEPENDENCY_AUDIT.md +118 -89
- package/docs/EVOLUTION_SHADOW_MODE.md +63 -63
- package/docs/EXTERNAL_REFERENCES.md +63 -58
- package/docs/GITLAB_FLOW.md +125 -125
- package/docs/GOVERNANCE_DASHBOARD.md +85 -85
- package/docs/MEMORY_BRAIN.md +104 -104
- package/docs/MEMORY_FABRIC.md +136 -134
- package/docs/README.md +102 -92
- package/docs/RUNTIME_EVIDENCE.md +101 -101
- package/docs/SKILL-REPOSITORY.md +57 -57
- package/docs/SKILL_RADAR.md +135 -122
- package/docs/THIRD_PARTY_SKILLS.md +57 -57
- package/docs/WORKFLOW_EVAL.md +151 -151
- package/docs/guides/DEVELOPMENT_WORKFLOW.md +80 -0
- package/docs/guides/GETTING_STARTED.md +50 -0
- package/docs/start/README.md +78 -72
- package/docs/start/agent-governance-demo.md +107 -107
- package/docs/start/quickstart.md +137 -127
- package/docs/start/workflow-upgrade.md +32 -8
- package/docs/workflow/README.md +67 -0
- package/docs/workflow/node-library.md +52 -0
- package/docs/workflow/templates/api-contract.md +29 -0
- package/docs/workflow/templates/architecture-review.md +23 -0
- package/docs/workflow/templates/db-change-plan.md +20 -0
- package/docs/workflow/templates/docs-impact.md +17 -0
- package/docs/workflow/templates/e2e-plan.md +20 -0
- package/docs/workflow/templates/explore.md +16 -0
- package/docs/workflow/templates/github-actions-scale-preflight.yml +32 -0
- package/docs/workflow/templates/mini-prd.md +16 -0
- package/docs/workflow/templates/plan.md +37 -0
- package/docs/workflow/templates/pre-push-scale-preflight.sh +8 -0
- package/docs/workflow/templates/product-smoke.md +61 -0
- package/docs/workflow/templates/reality-check.md +28 -0
- package/docs/workflow/templates/resource-cleanup.md +17 -0
- package/docs/workflow/templates/resource-impact.md +25 -0
- package/docs/workflow/templates/review.md +12 -0
- package/docs/workflow/templates/runtime.md +23 -0
- package/docs/workflow/templates/security-review.md +26 -0
- package/docs/workflow/templates/skill-evidence.md +33 -0
- package/docs/workflow/templates/skill-plan.md +39 -0
- package/docs/workflow/templates/spec.md +17 -0
- package/docs/workflow/templates/standards-impact.md +28 -0
- package/docs/workflow/templates/summary.md +16 -0
- package/docs/workflow/templates/tasks.md +8 -0
- package/docs/workflow/templates/ui-spec.md +29 -0
- package/docs/workflow/templates/verification.md +20 -0
- package/docs/workflow/templates/visual-review.md +20 -0
- package/examples/demo-projects/agent-governance-demo/CONTEXT.md +14 -14
- package/examples/demo-projects/agent-governance-demo/README.md +48 -48
- package/examples/demo-projects/agent-governance-demo/docs/CONTEXT-MAP.md +14 -14
- package/examples/demo-projects/agent-governance-demo/package.json +22 -21
- package/examples/demo-projects/agent-governance-demo/src/oauth-state.ts +39 -39
- package/examples/demo-projects/agent-governance-demo/tests/oauth-state.test.ts +52 -52
- package/package.json +95 -78
|
@@ -1,138 +1,138 @@
|
|
|
1
|
-
# Code Intelligence
|
|
2
|
-
|
|
3
|
-
SCALE uses an adapter-first code intelligence layer. It can consume external code graph tools when they exist, 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
|
-
Create the optional provider configuration:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
scale codegraph init
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Inspect provider availability:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
scale codegraph status
|
|
25
|
-
scale codegraph status --json
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Query code intelligence:
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
scale codegraph query "UserService.create"
|
|
32
|
-
scale codegraph impact --symbol UserService.create
|
|
33
|
-
scale codegraph context --symbol UserService.create --budget 2000
|
|
34
|
-
scale codegraph roi --symbol UserService.create
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Configuration
|
|
38
|
-
|
|
39
|
-
The configuration file lives at:
|
|
40
|
-
|
|
41
|
-
```text
|
|
42
|
-
.scale/code-intelligence.json
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Default shape:
|
|
46
|
-
|
|
47
|
-
```json
|
|
48
|
-
{
|
|
49
|
-
"version": "1.0",
|
|
50
|
-
"providers": [
|
|
51
|
-
{
|
|
52
|
-
"id": "codegraph",
|
|
53
|
-
"type": "external-cli",
|
|
54
|
-
"enabled": true,
|
|
55
|
-
"command": "codegraph",
|
|
56
|
-
"capabilities": ["symbols", "callers", "callees", "impact", "context"]
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"id": "graphify",
|
|
60
|
-
"type": "artifact",
|
|
61
|
-
"enabled": true,
|
|
62
|
-
"manifest": "graphify-out/GRAPH_REPORT.md",
|
|
63
|
-
"capabilities": ["summary", "module-map", "context"]
|
|
64
|
-
}
|
|
65
|
-
],
|
|
66
|
-
"fallback": {
|
|
67
|
-
"enabled": true,
|
|
68
|
-
"tools": ["internal-scan", "rg", "read"]
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Provider Types
|
|
74
|
-
|
|
75
|
-
| Type | Use |
|
|
76
|
-
| --- | --- |
|
|
77
|
-
| `external-cli` | Detects an installed external code graph command. SCALE does not auto-install it. The first version treats this as availability evidence until a stable command contract is configured. |
|
|
78
|
-
| `artifact` | Reads a local graph manifest or report file. JSON manifests can provide symbol impact data. |
|
|
79
|
-
| fallback | Uses a bounded internal source scan when providers are unavailable or return no hits. |
|
|
80
|
-
|
|
81
|
-
## JSON Artifact Provider
|
|
82
|
-
|
|
83
|
-
Artifact providers can point at a JSON manifest:
|
|
84
|
-
|
|
85
|
-
```json
|
|
86
|
-
{
|
|
87
|
-
"symbols": [
|
|
88
|
-
{
|
|
89
|
-
"name": "UserService.create",
|
|
90
|
-
"file": "src/user.ts",
|
|
91
|
-
"callers": ["src/api.ts"],
|
|
92
|
-
"callees": ["src/db.ts"]
|
|
93
|
-
}
|
|
94
|
-
],
|
|
95
|
-
"files": [
|
|
96
|
-
{
|
|
97
|
-
"path": "src/user.ts",
|
|
98
|
-
"symbols": ["UserService.create"]
|
|
99
|
-
}
|
|
100
|
-
]
|
|
101
|
-
}
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
This allows SCALE to answer impact queries without reading the whole repository.
|
|
105
|
-
|
|
106
|
-
## ROI Metrics
|
|
107
|
-
|
|
108
|
-
Code intelligence reports include:
|
|
109
|
-
|
|
110
|
-
| Metric | Meaning |
|
|
111
|
-
| --- | --- |
|
|
112
|
-
| `graphHits` | Number of hits from graph providers. |
|
|
113
|
-
| `fallbackCount` | Whether fallback was needed. |
|
|
114
|
-
| `baselineFileReads` | Estimated broad exploration file reads. |
|
|
115
|
-
| `recommendedFileReads` | Scoped file reads recommended by the query result. |
|
|
116
|
-
| `fileReadsSaved` | Estimated avoided reads. |
|
|
117
|
-
| `toolCallsSaved` | Estimated avoided exploration tool calls. |
|
|
118
|
-
|
|
119
|
-
These numbers are deliberately conservative. They are a local signal for whether graph-assisted exploration is worth keeping default for a task class.
|
|
120
|
-
|
|
121
|
-
## Governance ROI
|
|
122
|
-
|
|
123
|
-
`scale governance roi` can include code intelligence:
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
scale governance roi --symbol UserService.create
|
|
127
|
-
scale governance roi --code-query createUser
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
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.
|
|
131
|
-
|
|
132
|
-
## Policy
|
|
133
|
-
|
|
134
|
-
- SCALE must run when no code graph provider is installed.
|
|
135
|
-
- Missing providers must produce explicit fallback, not silent success.
|
|
136
|
-
- External tools are detected but not installed automatically.
|
|
137
|
-
- Source files are read only through a bounded fallback scan.
|
|
138
|
-
- Large generated graph outputs should stay outside default prompt context; use summaries and file paths.
|
|
1
|
+
# Code Intelligence
|
|
2
|
+
|
|
3
|
+
SCALE uses an adapter-first code intelligence layer. It can consume external code graph tools when they exist, 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
|
+
Create the optional provider configuration:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
scale codegraph init
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Inspect provider availability:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
scale codegraph status
|
|
25
|
+
scale codegraph status --json
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Query code intelligence:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
scale codegraph query "UserService.create"
|
|
32
|
+
scale codegraph impact --symbol UserService.create
|
|
33
|
+
scale codegraph context --symbol UserService.create --budget 2000
|
|
34
|
+
scale codegraph roi --symbol UserService.create
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Configuration
|
|
38
|
+
|
|
39
|
+
The configuration file lives at:
|
|
40
|
+
|
|
41
|
+
```text
|
|
42
|
+
.scale/code-intelligence.json
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Default shape:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"version": "1.0",
|
|
50
|
+
"providers": [
|
|
51
|
+
{
|
|
52
|
+
"id": "codegraph",
|
|
53
|
+
"type": "external-cli",
|
|
54
|
+
"enabled": true,
|
|
55
|
+
"command": "codegraph",
|
|
56
|
+
"capabilities": ["symbols", "callers", "callees", "impact", "context"]
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"id": "graphify",
|
|
60
|
+
"type": "artifact",
|
|
61
|
+
"enabled": true,
|
|
62
|
+
"manifest": "graphify-out/GRAPH_REPORT.md",
|
|
63
|
+
"capabilities": ["summary", "module-map", "context"]
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"fallback": {
|
|
67
|
+
"enabled": true,
|
|
68
|
+
"tools": ["internal-scan", "rg", "read"]
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Provider Types
|
|
74
|
+
|
|
75
|
+
| Type | Use |
|
|
76
|
+
| --- | --- |
|
|
77
|
+
| `external-cli` | Detects an installed external code graph command. SCALE does not auto-install it. The first version treats this as availability evidence until a stable command contract is configured. |
|
|
78
|
+
| `artifact` | Reads a local graph manifest or report file. JSON manifests can provide symbol impact data. |
|
|
79
|
+
| fallback | Uses a bounded internal source scan when providers are unavailable or return no hits. |
|
|
80
|
+
|
|
81
|
+
## JSON Artifact Provider
|
|
82
|
+
|
|
83
|
+
Artifact providers can point at a JSON manifest:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"symbols": [
|
|
88
|
+
{
|
|
89
|
+
"name": "UserService.create",
|
|
90
|
+
"file": "src/user.ts",
|
|
91
|
+
"callers": ["src/api.ts"],
|
|
92
|
+
"callees": ["src/db.ts"]
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
"files": [
|
|
96
|
+
{
|
|
97
|
+
"path": "src/user.ts",
|
|
98
|
+
"symbols": ["UserService.create"]
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
This allows SCALE to answer impact queries without reading the whole repository.
|
|
105
|
+
|
|
106
|
+
## ROI Metrics
|
|
107
|
+
|
|
108
|
+
Code intelligence reports include:
|
|
109
|
+
|
|
110
|
+
| Metric | Meaning |
|
|
111
|
+
| --- | --- |
|
|
112
|
+
| `graphHits` | Number of hits from graph providers. |
|
|
113
|
+
| `fallbackCount` | Whether fallback was needed. |
|
|
114
|
+
| `baselineFileReads` | Estimated broad exploration file reads. |
|
|
115
|
+
| `recommendedFileReads` | Scoped file reads recommended by the query result. |
|
|
116
|
+
| `fileReadsSaved` | Estimated avoided reads. |
|
|
117
|
+
| `toolCallsSaved` | Estimated avoided exploration tool calls. |
|
|
118
|
+
|
|
119
|
+
These numbers are deliberately conservative. They are a local signal for whether graph-assisted exploration is worth keeping default for a task class.
|
|
120
|
+
|
|
121
|
+
## Governance ROI
|
|
122
|
+
|
|
123
|
+
`scale governance roi` can include code intelligence:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
scale governance roi --symbol UserService.create
|
|
127
|
+
scale governance roi --code-query createUser
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
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.
|
|
131
|
+
|
|
132
|
+
## Policy
|
|
133
|
+
|
|
134
|
+
- SCALE must run when no code graph provider is installed.
|
|
135
|
+
- Missing providers must produce explicit fallback, not silent success.
|
|
136
|
+
- External tools are detected but not installed automatically.
|
|
137
|
+
- Source files are read only through a bounded fallback scan.
|
|
138
|
+
- Large generated graph outputs should stay outside default prompt context; use summaries and file paths.
|
package/docs/CONTEXT_BUDGET.md
CHANGED
|
@@ -1,113 +1,155 @@
|
|
|
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 2500 --max-task 8000
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
scale
|
|
50
|
-
--task
|
|
51
|
-
--
|
|
52
|
-
--
|
|
53
|
-
--
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
|
103
|
-
|
|
|
104
|
-
|
|
|
105
|
-
|
|
|
106
|
-
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
##
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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 2500 --max-task 8000
|
|
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, 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 8000 \
|
|
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
|
+
## Progressive Governance
|
|
130
|
+
|
|
131
|
+
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`.
|
|
132
|
+
|
|
133
|
+
Examples:
|
|
134
|
+
|
|
135
|
+
| Signal | Mode |
|
|
136
|
+
| --- | --- |
|
|
137
|
+
| README typo | `minimal` |
|
|
138
|
+
| normal implementation task | `standard` |
|
|
139
|
+
| UI, browser, E2E, public interface, or cross-module work | `expanded` |
|
|
140
|
+
| auth, permission, secret, database, migration, production config, release, or destructive operation | `critical` |
|
|
141
|
+
|
|
142
|
+
This is not a replacement for verification. It only decides which governance behavior should activate.
|
|
143
|
+
|
|
144
|
+
## Governance ROI
|
|
145
|
+
|
|
146
|
+
`scale governance roi` reports both benefit and overhead. In v0.27.0, `scale ai-os plan` also attaches ROI modules for:
|
|
147
|
+
|
|
148
|
+
- `context-budget`
|
|
149
|
+
- `context-compiler`
|
|
150
|
+
- `memory-provider-runtime`
|
|
151
|
+
- `skill-routing-engine`
|
|
152
|
+
- `progressive-governance`
|
|
153
|
+
|
|
154
|
+
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.
|
|
155
|
+
|