fix(audit): 修复深度审计 P2 问题 — 自主授权后端守卫、反思历史累积、心跳持久化
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
- M5-补: hand_execute/skill_execute 接收 autonomy_level 参数,后端三层守卫
(supervised 全部审批 / assisted 尊重 needs_approval / autonomous 跳过)
- M3: hand_approve/hand_cancel 移除 _hand_name 下划线,添加审计日志
- M4-补: 反思历史累积存储到 reflection:history:{agent_id} 数组(最多20条)
get_history 优先读持久化历史,保留 latest key 向后兼容
- 心跳历史: VikingStorage 持久化 HeartbeatResult 数组,tick() 也存历史
heartbeat_init 恢复历史,重启后不丢失
- L2: 确认 gatewayStore 仅注释引用,无需修改
- 身份回滚: 确认 IdentityChangeProposal.tsx 已实现 HistoryItem + restoreSnapshot
- 更新 DEEP_AUDIT_REPORT.md 完成度 72% (核心 92%, 真实可用 80%)
This commit is contained in:
@@ -684,10 +684,11 @@ export class KernelClient {
|
||||
/**
|
||||
* Trigger/execute a hand
|
||||
*/
|
||||
async triggerHand(name: string, params?: Record<string, unknown>): Promise<{ runId: string; status: string }> {
|
||||
async triggerHand(name: string, params?: Record<string, unknown>, autonomyLevel?: string): Promise<{ runId: string; status: string }> {
|
||||
const result = await invoke<{ instance_id: string; status: string }>('hand_execute', {
|
||||
id: name,
|
||||
input: params || {},
|
||||
...(autonomyLevel ? { autonomyLevel } : {}),
|
||||
});
|
||||
return { runId: result.instance_id, status: result.status };
|
||||
}
|
||||
@@ -810,6 +811,8 @@ export class KernelClient {
|
||||
|
||||
/**
|
||||
* Execute a skill
|
||||
* Checks autonomy authorization before execution and passes the autonomy
|
||||
* level to the backend for defense-in-depth enforcement.
|
||||
*/
|
||||
async executeSkill(id: string, input?: Record<string, unknown>): Promise<{
|
||||
success: boolean;
|
||||
@@ -817,10 +820,23 @@ export class KernelClient {
|
||||
error?: string;
|
||||
durationMs?: number;
|
||||
}> {
|
||||
// Autonomy check before executing skill
|
||||
const { canAutoExecute, getAutonomyManager } = await import('./autonomy-manager');
|
||||
const { canProceed, decision } = canAutoExecute('skill_install', 5);
|
||||
if (!canProceed) {
|
||||
return {
|
||||
success: false,
|
||||
error: `自主授权拒绝: ${decision.reason}`,
|
||||
};
|
||||
}
|
||||
|
||||
const autonomyLevel = getAutonomyManager().getConfig().level;
|
||||
|
||||
return invoke('skill_execute', {
|
||||
id,
|
||||
context: {},
|
||||
input: input || {},
|
||||
autonomyLevel,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user