Repository navigation
Expand file tree
/
Copy pathcode_mode.rs
More file actions
117 lines (114 loc) · 5.77 KB
/
Copy pathcode_mode.rs
File metadata and controls
117 lines (114 loc) · 5.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
114
115
116
117
use super::ToolVisibility::ModelVisible;
use super::{
adaptive_runtime_direct, def, model_spec, permission_risk, requires_explicit_business_session,
ToolDefinition, PERMISSION_RISK_WRITE, TOOL_CATEGORY_RUNTIME,
};
use crate::metadata::{
ToolPathHint::None as NoPath,
ToolRisk::{JobRun, ProjectWrite, Read},
JOB_RUN, PROJECT_READ, PROJECT_WRITE, TOOL_PROVIDER_CONTROL,
};
const RESULT_AUDIT_FIELDS: &[super::ToolAuditResultField] = &[
super::ToolAuditResultField::pointer("tool_calls", "/stats/tool_calls"),
super::ToolAuditResultField::pointer("max_in_flight", "/stats/max_in_flight"),
super::ToolAuditResultField::pointer("duration_ms", "/stats/duration_ms"),
super::ToolAuditResultField::pointer("returned_bytes", "/stats/returned_bytes"),
super::ToolAuditResultField::value("failure_kind"),
];
const EFFECTFUL_RESULT_AUDIT_FIELDS: &[super::ToolAuditResultField] = &[
super::ToolAuditResultField::pointer(
"consequential_calls",
"/effect_receipt/consequential_calls",
),
super::ToolAuditResultField::pointer("known_results", "/effect_receipt/known_results"),
super::ToolAuditResultField::pointer("job_handoffs", "/effect_receipt/job_handoffs"),
super::ToolAuditResultField::pointer("outcome_unknown", "/effect_receipt/outcome_unknown"),
super::ToolAuditResultField::value("failure_kind"),
];
pub(super) const DEFINITIONS: &[ToolDefinition] = &[
adaptive_runtime_direct(
requires_explicit_business_session(model_spec(
def(
"execute_code_mode",
super::ToolAuditPolicy::typed_fields(RESULT_AUDIT_FIELDS),
ModelVisible,
TOOL_CATEGORY_RUNTIME,
None,
TOOL_PROVIDER_CONTROL,
super::ToolSemanticContract {
effect: super::ToolEffect::Observe,
risk: Read,
approval: super::ToolApprovalPolicy::None,
idempotency: super::ToolIdempotency::PureRead,
},
Some(PROJECT_READ),
true,
NoPath,
false,
false,
super::ToolSessionEvidencePolicy::NONE
.review(super::ToolReviewEvidence::ReadOnlyInspection),
),
"Read-only Code Mode for related inspections. Prefer a direct tool for one simple observation. Use Promise.all only for independent calls; keep dependent follow-ups sequential inside one cell. Filter child results before text(value); never a raw-result dump. Project before the outer-output limit. Children keep canonical authority; no shell/fs/network/mutation/validation/Jobs.",
)),
45,
super::ToolDirectReason::CoreWorkflow,
),
adaptive_runtime_direct(
requires_explicit_business_session(model_spec(
def(
"execute_effectful_code_mode",
super::ToolAuditPolicy::typed_fields(EFFECTFUL_RESULT_AUDIT_FIELDS),
ModelVisible,
TOOL_CATEGORY_RUNTIME,
None,
TOOL_PROVIDER_CONTROL,
super::ToolSemanticContract {
effect: super::ToolEffect::Execute,
risk: JobRun,
approval: super::ToolApprovalPolicy::Standard,
idempotency: super::ToolIdempotency::NonIdempotent,
},
Some(JOB_RUN),
true,
NoPath,
false,
false,
super::ToolSessionEvidencePolicy::NONE,
),
"Validation Code Mode for E1 reads plus project_validate, cargo_check and cargo_test. Prefer project_validate for portable validation; use Cargo validator specialists when their advanced contract matters. Distill results before text(value). Children retain canonical Project/Session, permission, validation and Job semantics. Plugin/MCP gateways, shell/process tools, nested Job observation and recursive Code Mode remain unavailable.",
)),
105,
super::ToolDirectReason::CoreWorkflow,
),
adaptive_runtime_direct(
permission_risk(
requires_explicit_business_session(model_spec(
super::require_all_scopes(def(
"execute_mutating_code_mode",
super::ToolAuditPolicy::typed_fields(EFFECTFUL_RESULT_AUDIT_FIELDS),
ModelVisible,
TOOL_CATEGORY_RUNTIME,
None,
TOOL_PROVIDER_CONTROL,
super::ToolSemanticContract {
effect: super::ToolEffect::Mutate,
risk: ProjectWrite,
approval: super::ToolApprovalPolicy::Standard,
idempotency: super::ToolIdempotency::NonIdempotent,
},
Some(PROJECT_WRITE),
true,
NoPath,
true,
true,
super::ToolSessionEvidencePolicy::NONE,
), &[PROJECT_WRITE, JOB_RUN]),
"Bounded coding Code Mode: adaptive E1 reads, at most one canonical edit_project_files attempt, then project_validate, cargo_check or cargo_test only after a successful known edit; a successful no-op may validate. Requires project:write and job:run; child authority remains canonical. Execution pass is not current-source proof: inspect source_state. Continue Jobs outside the cell using exact effect_receipt children. Plugin/MCP gateways, shell/process tools, nested Job observation, alternate writes, recursion and whole-program retry remain unavailable.",
)),
PERMISSION_RISK_WRITE,
),
65,
super::ToolDirectReason::CoreWorkflow,
),
];