@arcforge/types 2.0.191 → 2.0.192
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/package.json +1 -1
- package/src/policy-shell.ts +63 -23
- package/src/policy.ts +10 -0
package/package.json
CHANGED
package/src/policy-shell.ts
CHANGED
|
@@ -139,34 +139,45 @@ export type ShellDecision = {
|
|
|
139
139
|
/**
|
|
140
140
|
* Decide one execution against the resolved `shell` policy.
|
|
141
141
|
*
|
|
142
|
+
* ── One rule ────────────────────────────────────────────────────────────────
|
|
143
|
+
*
|
|
144
|
+
* **An explicit allow allows. An explicit deny denies. Silence asks.**
|
|
145
|
+
*
|
|
146
|
+
* Every branch below is an application of that sentence, and the sentence is
|
|
147
|
+
* what makes the surface predictable: a user reading their own policy can
|
|
148
|
+
* answer "what happens to a program I have not mentioned?" without knowing
|
|
149
|
+
* which of four code paths their command takes.
|
|
150
|
+
*
|
|
142
151
|
* Order is deliberate and each step is a different question:
|
|
143
152
|
* 1. Is this a shell, and is `raw` off? A shell defeats every rule below it,
|
|
144
153
|
* so it is answered first and separately.
|
|
145
154
|
* 2. Does `deny` name the program? Deny always beats allow.
|
|
146
|
-
* 3. Does `allow` admit it? An allowlist that names nothing matching
|
|
147
|
-
*
|
|
155
|
+
* 3. Does `allow` admit it? An allowlist that names nothing matching has said
|
|
156
|
+
* nothing about this program, so it asks.
|
|
148
157
|
* 4. Do the argument patterns object? Advisory, and last.
|
|
158
|
+
* 5. Nothing spoke at all → ask.
|
|
159
|
+
*
|
|
160
|
+
* ── Why there is no `fallback` parameter any more ───────────────────────────
|
|
161
|
+
*
|
|
162
|
+
* There used to be one, because two callers wanted opposite answers for an
|
|
163
|
+
* undeclared surface: the capsule denied (it runs foreign, model-emitted code
|
|
164
|
+
* and must never grant by omission) and Axon allowed ("I did not set a policy"
|
|
165
|
+
* meaning a personal tool with the user's own privileges, not a brick).
|
|
166
|
+
*
|
|
167
|
+
* Both stances are now produced by ESCALATION plus its degradation, without a
|
|
168
|
+
* knob. A bare `Capsule()` has no decider, so `Escalation` answers false
|
|
169
|
+
* immediately and it still runs nothing. A user at a TUI is asked, and
|
|
170
|
+
* answering "always" writes the grant. The parameter was a second way to
|
|
171
|
+
* express something the escalation path already expresses correctly, and the
|
|
172
|
+
* two could drift.
|
|
173
|
+
*
|
|
174
|
+
* The cost of the old shape was concrete: an agent with no policy — which is
|
|
175
|
+
* every agent in its first minutes — got `shell.run:axon denied · no rule
|
|
176
|
+
* permits it` and had nowhere to go but the docs.
|
|
149
177
|
*/
|
|
150
178
|
export function decideShell(
|
|
151
179
|
shell: ResolvedCapsulePolicy["shell"],
|
|
152
180
|
argv: string[],
|
|
153
|
-
/**
|
|
154
|
-
* What an UNDECLARED `shell` surface means.
|
|
155
|
-
*
|
|
156
|
-
* The two callers sit on opposite sides of a trust boundary and need
|
|
157
|
-
* opposite answers, which is why this is a parameter rather than a constant:
|
|
158
|
-
*
|
|
159
|
-
* "deny" — the CAPSULE. It runs foreign, model-emitted code and must
|
|
160
|
-
* never grant capability by omission. A bare `Capsule()` with no
|
|
161
|
-
* policy can run nothing.
|
|
162
|
-
* "allow" — AXON. It is wiring a box for its own declared blueprint, and
|
|
163
|
-
* "I did not set a security policy" means a personal tool with
|
|
164
|
-
* the user's own privileges, not a brick.
|
|
165
|
-
*
|
|
166
|
-
* Getting this wrong in either direction is silent: one bricks every
|
|
167
|
-
* unconfigured capsule, the other hands an unconfigured sandbox a shell.
|
|
168
|
-
*/
|
|
169
|
-
fallback: "allow" | "deny" = "deny",
|
|
170
181
|
/**
|
|
171
182
|
* The command as the caller received it, before splitting.
|
|
172
183
|
*
|
|
@@ -177,11 +188,27 @@ export function decideShell(
|
|
|
177
188
|
*/
|
|
178
189
|
command?: string,
|
|
179
190
|
): ShellDecision {
|
|
180
|
-
// No shell block at all
|
|
181
|
-
|
|
191
|
+
// No shell block at all — nobody has spoken, so ask. Identical to a block
|
|
192
|
+
// that declares nothing (`shell: {}`), which is the point: whether a user
|
|
193
|
+
// omitted the key or wrote an empty object is not a security decision, and
|
|
194
|
+
// reading those two as different postures is how `{}` came to mean "allow
|
|
195
|
+
// everything" while omitting it meant "deny everything".
|
|
196
|
+
if (!shell) return { verdict: "escalate", program: programName(argv[0] ?? ""), reason: "no-policy" }
|
|
182
197
|
|
|
183
198
|
const { program, shell: resolvedShell } = resolveProgram(argv)
|
|
184
199
|
|
|
200
|
+
/*
|
|
201
|
+
* Did any rule actually PERMIT this program, as opposed to merely failing
|
|
202
|
+
* to object to it?
|
|
203
|
+
*
|
|
204
|
+
* The function used to end with a bare `return allow`, which answered both
|
|
205
|
+
* questions the same way — an allowlist that named the program, and a
|
|
206
|
+
* policy that had never heard of it. The first is a grant somebody wrote;
|
|
207
|
+
* the second is silence. Collapsing them is what made an undeclared
|
|
208
|
+
* program run without anyone deciding it should.
|
|
209
|
+
*/
|
|
210
|
+
let permitted = false
|
|
211
|
+
|
|
185
212
|
// A chained/redirected/substituted command line is a SHELL PROGRAM, whatever
|
|
186
213
|
// its first token is — see isShellCommand. Without this the decision was
|
|
187
214
|
// made about `pwd` while `/bin/sh -c` ran `pwd && git push --force`.
|
|
@@ -199,9 +226,12 @@ export function decideShell(
|
|
|
199
226
|
* author had never written. Asking is the honest answer to a question
|
|
200
227
|
* nobody has answered, and the prompt can say what a shell actually is.
|
|
201
228
|
*/
|
|
202
|
-
if (isShell
|
|
229
|
+
if (isShell) {
|
|
203
230
|
if (shell.raw === false) return { verdict: "deny", program, reason: "raw-shell" }
|
|
204
|
-
|
|
231
|
+
// `raw: true` is somebody writing "yes, shell lines are fine" — an
|
|
232
|
+
// explicit grant, so the program does not have to be named again below.
|
|
233
|
+
if (shell.raw !== true) return { verdict: "escalate", program, reason: "raw-shell" }
|
|
234
|
+
permitted = true
|
|
205
235
|
}
|
|
206
236
|
|
|
207
237
|
// Deny always beats allow, and always means DENY: this one is a rule
|
|
@@ -227,6 +257,7 @@ export function decideShell(
|
|
|
227
257
|
*/
|
|
228
258
|
const admitted = shell.allow.some(pattern => policyGlobMatch(pattern, program))
|
|
229
259
|
if (!admitted) return { verdict: "escalate", program, reason: "not-allowed" }
|
|
260
|
+
permitted = true
|
|
230
261
|
}
|
|
231
262
|
|
|
232
263
|
// Argument patterns — advisory, and only consulted once the program itself
|
|
@@ -253,6 +284,15 @@ export function decideShell(
|
|
|
253
284
|
}
|
|
254
285
|
}
|
|
255
286
|
|
|
287
|
+
// Nothing objected — but nothing permitted it either. Ask.
|
|
288
|
+
//
|
|
289
|
+
// This is the case that reaches a new user: an agent with no `policy` block
|
|
290
|
+
// at all, running its first command. Answering "allow" here is a grant
|
|
291
|
+
// nobody made; answering "deny" is a refusal nobody made and leaves them
|
|
292
|
+
// reading docs. The honest answer to a question no one has answered is to
|
|
293
|
+
// ask it, and "always" writes the rule they would have gone looking for.
|
|
294
|
+
if (!permitted) return { verdict: "escalate", program, reason: "no-policy" }
|
|
295
|
+
|
|
256
296
|
return { verdict: "allow", program, reason: "allowed" }
|
|
257
297
|
}
|
|
258
298
|
|
package/src/policy.ts
CHANGED
|
@@ -515,6 +515,16 @@ export type PolicyResponseCommand = {
|
|
|
515
515
|
id: string
|
|
516
516
|
type: "policy:response"
|
|
517
517
|
allow: boolean
|
|
518
|
+
/**
|
|
519
|
+
* Why a refusal was a refusal, when it was not a person saying no.
|
|
520
|
+
*
|
|
521
|
+
* "headless" means there was nobody to ask — a script, CI, a deployment.
|
|
522
|
+
* Without it every such denial recorded `escalation-denied`, which reads as
|
|
523
|
+
* a decision someone made and sends whoever is debugging a blocked agent
|
|
524
|
+
* looking for the person who made it. Absent on an allow, and absent when a
|
|
525
|
+
* decider genuinely declined.
|
|
526
|
+
*/
|
|
527
|
+
reason?: "headless"
|
|
518
528
|
}
|
|
519
529
|
|
|
520
530
|
export type PolicyCall = {
|