2026-02-09 19:33:42 -07:00
|
|
|
#pragma once
|
|
|
|
|
// Step 157: Agent role permissions
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
|
|
enum class AgentRole {
|
|
|
|
|
Linter = 0,
|
|
|
|
|
Refactor = 1,
|
|
|
|
|
Generator = 2
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct AgentPermissionPolicy {
|
|
|
|
|
static const char* roleLabel(AgentRole role) {
|
|
|
|
|
switch (role) {
|
|
|
|
|
case AgentRole::Linter: return "Linter";
|
|
|
|
|
case AgentRole::Refactor: return "Refactor";
|
|
|
|
|
case AgentRole::Generator: return "Generator";
|
|
|
|
|
}
|
|
|
|
|
return "Linter";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static AgentRole roleFromString(const std::string& role) {
|
|
|
|
|
std::string lower = role;
|
|
|
|
|
std::transform(lower.begin(), lower.end(), lower.begin(),
|
|
|
|
|
[](unsigned char c) { return (char)std::tolower(c); });
|
|
|
|
|
if (lower == "refactor") return AgentRole::Refactor;
|
|
|
|
|
if (lower == "generator") return AgentRole::Generator;
|
|
|
|
|
return AgentRole::Linter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool canInvoke(AgentRole role, const std::string& method) {
|
2026-02-10 07:31:01 -07:00
|
|
|
// Read-only methods: all roles
|
2026-02-09 19:33:42 -07:00
|
|
|
if (method == "getAST" ||
|
|
|
|
|
method == "getAnnotationSuggestions" ||
|
|
|
|
|
method == "recordAnnotationFeedback" ||
|
2026-02-10 07:31:01 -07:00
|
|
|
method == "setAgentRole" ||
|
|
|
|
|
method == "getInScopeSymbols" ||
|
|
|
|
|
method == "getCallHierarchy" ||
|
|
|
|
|
method == "getDependencyGraph" ||
|
|
|
|
|
method == "runPipeline" ||
|
|
|
|
|
method == "parseSource" ||
|
|
|
|
|
method == "generateFromAST" ||
|
2026-02-11 05:59:02 +00:00
|
|
|
method == "projectLanguage" ||
|
|
|
|
|
method == "fileRead" ||
|
|
|
|
|
method == "workspaceList" ||
|
2026-02-11 06:29:17 +00:00
|
|
|
method == "fileDiff" ||
|
|
|
|
|
method == "getASTSubtree" ||
|
2026-02-11 15:36:24 +00:00
|
|
|
method == "getASTDiff" ||
|
2026-02-11 15:41:56 +00:00
|
|
|
method == "getDiagnostics" ||
|
2026-02-11 15:45:31 +00:00
|
|
|
method == "getDiagnosticsDelta" ||
|
2026-02-11 16:06:54 +00:00
|
|
|
method == "getQuickFixes" ||
|
2026-02-11 19:43:53 +00:00
|
|
|
method == "batchQuery" ||
|
|
|
|
|
method == "listBuffers" ||
|
|
|
|
|
method == "setActiveBuffer" ||
|
2026-02-11 20:06:46 +00:00
|
|
|
method == "indexWorkspace" ||
|
2026-02-11 20:13:46 +00:00
|
|
|
method == "getImportGraph" ||
|
2026-02-11 20:27:47 +00:00
|
|
|
method == "getProjectDiagnostics" ||
|
Steps 266-268: Phase 10a — semantic annotation core + sidecar persistence (32/32 tests)
Step 266: 5 semantic annotation AST types (Intent, Complexity, Risk,
Contract, SemanticTag) with JSON roundtrip and compact AST integration.
Step 267: Sidecar AST persistence (.whetstone/<file>.ast.json) with
save/load/list RPC methods, MCP tools, and permission enforcement.
Step 268: Phase 10a integration tests — multi-file sidecar workflow,
all 5 types in compact view, idempotent roundtrip, source isolation.
Also includes Sprint 10 plan, GUI/installer polish, and Emacs integration fixes.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 16:01:56 +00:00
|
|
|
method == "searchProject" ||
|
|
|
|
|
method == "loadAnnotatedAST" ||
|
|
|
|
|
method == "listAnnotatedFiles" ||
|
2026-02-24 11:13:31 -07:00
|
|
|
method == "getSemanticHashTable" ||
|
|
|
|
|
method == "listSemanticHashTables" ||
|
|
|
|
|
method == "getSemanticHashLock" ||
|
Steps 266-268: Phase 10a — semantic annotation core + sidecar persistence (32/32 tests)
Step 266: 5 semantic annotation AST types (Intent, Complexity, Risk,
Contract, SemanticTag) with JSON roundtrip and compact AST integration.
Step 267: Sidecar AST persistence (.whetstone/<file>.ast.json) with
save/load/list RPC methods, MCP tools, and permission enforcement.
Step 268: Phase 10a integration tests — multi-file sidecar workflow,
all 5 types in compact view, idempotent roundtrip, source isolation.
Also includes Sprint 10 plan, GUI/installer polish, and Emacs integration fixes.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 16:01:56 +00:00
|
|
|
method == "getSemanticAnnotations" ||
|
Phase 10e WIP: environment layer core + host boundary nodes
EnvironmentSpec, CapabilityRequirement, HostCall, ScheduleTask, ModuleLoad
classes created. All wired through Serialization.h, CompactAST.h,
SidecarPersistence.h, HeadlessAgentRPCHandler.h (setEnvironment,
getEnvironment, validateEnvironment, getLoweringHints RPCs).
Tests for steps 284-285 written. Steps 286-289 tests remaining.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 18:41:16 +00:00
|
|
|
method == "getUnannotatedNodes" ||
|
|
|
|
|
method == "getEnvironment" ||
|
|
|
|
|
method == "validateEnvironment" ||
|
Steps 309-319: Sprint 11 Phases 11d-e — Kotlin/C# languages + workflow annotation foundation
Phase 11d (Steps 309-313): Kotlin + C# parsers and generators
- KotlinParser (regex-based): fun, suspend fun, class, data class, val/var
- KotlinGenerator: idiomatic Kotlin output with type mappings
- CSharpParser (regex-based): methods, async, class, interface
- CSharpGenerator: Allman braces, foreach, Task async, LINQ types
- Pipeline integration for both languages, 10 parsers + 10 generators
Phase 11e (Steps 314-319): Workflow annotation foundation
- AnnotationInference: generalized multi-subject inference engine
- Subject 9 routing annotations: ContextWidth, Review, Ambiguity,
Automatability, Priority, ImplementationStatus
- SkeletonAST: project specification before code exists
- Architect tooling: createSkeleton, addSkeletonNode, getProjectModel,
inferAnnotations RPCs + 4 MCP tools (42+ total)
- Inference-to-routing bridge: complexity→ambiguity, getter→deterministic
- TrainingDataExporter + TrainingDataGenerator scaffolding
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 15:50:06 -07:00
|
|
|
method == "getLoweringHints" ||
|
|
|
|
|
method == "getProjectModel" ||
|
2026-02-15 17:00:52 -07:00
|
|
|
method == "inferAnnotations" ||
|
|
|
|
|
method == "getWorkflowState" ||
|
|
|
|
|
method == "getReadyTasks" ||
|
2026-02-15 19:20:00 -07:00
|
|
|
method == "getWorkItem" ||
|
2026-02-15 19:23:06 -07:00
|
|
|
method == "getRoutingExplanation" ||
|
2026-02-16 12:47:58 -07:00
|
|
|
method == "getReviewPolicy" ||
|
2026-02-16 16:19:52 -07:00
|
|
|
method == "getReviewQueue" ||
|
|
|
|
|
method == "getReviewContext" ||
|
2026-02-16 12:47:58 -07:00
|
|
|
method == "getBlockers" ||
|
2026-02-16 13:01:15 -07:00
|
|
|
method == "getProgress" ||
|
|
|
|
|
method == "getEventStream" ||
|
|
|
|
|
method == "getRecentEvents") {
|
2026-02-09 19:33:42 -07:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-17 20:56:12 -07:00
|
|
|
if (method == "setWorkspaceContext") {
|
|
|
|
|
return role == AgentRole::Refactor || role == AgentRole::Generator;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-10 07:31:01 -07:00
|
|
|
// Mutation methods: Refactor and Generator only
|
|
|
|
|
if (method == "generateCode" ||
|
|
|
|
|
method == "applyMutation" ||
|
|
|
|
|
method == "applyAnnotationSuggestion" ||
|
2026-02-11 05:59:02 +00:00
|
|
|
method == "applyBatch" ||
|
|
|
|
|
method == "fileWrite" ||
|
2026-02-11 15:41:56 +00:00
|
|
|
method == "fileCreate" ||
|
2026-02-11 19:43:53 +00:00
|
|
|
method == "applyQuickFix" ||
|
|
|
|
|
method == "openFile" ||
|
2026-02-11 20:27:47 +00:00
|
|
|
method == "closeFile" ||
|
2026-02-12 01:27:23 +00:00
|
|
|
method == "renameSymbol" ||
|
|
|
|
|
method == "saveBuffer" ||
|
|
|
|
|
method == "saveAllBuffers" ||
|
|
|
|
|
method == "undo" ||
|
Steps 266-268: Phase 10a — semantic annotation core + sidecar persistence (32/32 tests)
Step 266: 5 semantic annotation AST types (Intent, Complexity, Risk,
Contract, SemanticTag) with JSON roundtrip and compact AST integration.
Step 267: Sidecar AST persistence (.whetstone/<file>.ast.json) with
save/load/list RPC methods, MCP tools, and permission enforcement.
Step 268: Phase 10a integration tests — multi-file sidecar workflow,
all 5 types in compact view, idempotent roundtrip, source isolation.
Also includes Sprint 10 plan, GUI/installer polish, and Emacs integration fixes.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 16:01:56 +00:00
|
|
|
method == "redo" ||
|
|
|
|
|
method == "saveAnnotatedAST" ||
|
2026-02-24 11:13:31 -07:00
|
|
|
method == "saveSemanticHashTable" ||
|
|
|
|
|
method == "setSemanticHashLock" ||
|
Steps 266-268: Phase 10a — semantic annotation core + sidecar persistence (32/32 tests)
Step 266: 5 semantic annotation AST types (Intent, Complexity, Risk,
Contract, SemanticTag) with JSON roundtrip and compact AST integration.
Step 267: Sidecar AST persistence (.whetstone/<file>.ast.json) with
save/load/list RPC methods, MCP tools, and permission enforcement.
Step 268: Phase 10a integration tests — multi-file sidecar workflow,
all 5 types in compact view, idempotent roundtrip, source isolation.
Also includes Sprint 10 plan, GUI/installer polish, and Emacs integration fixes.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 16:01:56 +00:00
|
|
|
method == "setSemanticAnnotation" ||
|
Phase 10e WIP: environment layer core + host boundary nodes
EnvironmentSpec, CapabilityRequirement, HostCall, ScheduleTask, ModuleLoad
classes created. All wired through Serialization.h, CompactAST.h,
SidecarPersistence.h, HeadlessAgentRPCHandler.h (setEnvironment,
getEnvironment, validateEnvironment, getLoweringHints RPCs).
Tests for steps 284-285 written. Steps 286-289 tests remaining.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 18:41:16 +00:00
|
|
|
method == "removeSemanticAnnotation" ||
|
Steps 309-319: Sprint 11 Phases 11d-e — Kotlin/C# languages + workflow annotation foundation
Phase 11d (Steps 309-313): Kotlin + C# parsers and generators
- KotlinParser (regex-based): fun, suspend fun, class, data class, val/var
- KotlinGenerator: idiomatic Kotlin output with type mappings
- CSharpParser (regex-based): methods, async, class, interface
- CSharpGenerator: Allman braces, foreach, Task async, LINQ types
- Pipeline integration for both languages, 10 parsers + 10 generators
Phase 11e (Steps 314-319): Workflow annotation foundation
- AnnotationInference: generalized multi-subject inference engine
- Subject 9 routing annotations: ContextWidth, Review, Ambiguity,
Automatability, Priority, ImplementationStatus
- SkeletonAST: project specification before code exists
- Architect tooling: createSkeleton, addSkeletonNode, getProjectModel,
inferAnnotations RPCs + 4 MCP tools (42+ total)
- Inference-to-routing bridge: complexity→ambiguity, getter→deterministic
- TrainingDataExporter + TrainingDataGenerator scaffolding
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 15:50:06 -07:00
|
|
|
method == "setEnvironment" ||
|
|
|
|
|
method == "createSkeleton" ||
|
2026-02-15 17:00:52 -07:00
|
|
|
method == "addSkeletonNode" ||
|
|
|
|
|
method == "createWorkflow" ||
|
|
|
|
|
method == "assignTask" ||
|
|
|
|
|
method == "completeTask" ||
|
|
|
|
|
method == "rejectTask" ||
|
2026-02-15 19:20:00 -07:00
|
|
|
method == "saveWorkflow" ||
|
|
|
|
|
method == "routeTask" ||
|
|
|
|
|
method == "routeAllReady" ||
|
2026-02-15 19:23:06 -07:00
|
|
|
method == "executeTask" ||
|
2026-02-16 12:47:58 -07:00
|
|
|
method == "setReviewPolicy" ||
|
2026-02-16 16:19:52 -07:00
|
|
|
method == "approveReviewItem" ||
|
|
|
|
|
method == "rejectReviewItem" ||
|
2026-02-16 12:47:58 -07:00
|
|
|
method == "orchestrateStep" ||
|
|
|
|
|
method == "orchestrateAdvance" ||
|
|
|
|
|
method == "orchestrateRunDeterministic" ||
|
|
|
|
|
method == "submitExternalResult") {
|
2026-02-09 19:33:42 -07:00
|
|
|
return role == AgentRole::Refactor || role == AgentRole::Generator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool canMutate(AgentRole role) {
|
|
|
|
|
return role == AgentRole::Refactor || role == AgentRole::Generator;
|
|
|
|
|
}
|
|
|
|
|
};
|