@archmax-ai/harness 0.9.0 → 1.0.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/README.md +58 -14
- package/dist/agent.d.ts +4 -6
- package/dist/agent.js +4 -6
- package/dist/agent.js.map +1 -1
- package/dist/assembly/compose.d.ts +5 -24
- package/dist/assembly/compose.js +28 -42
- package/dist/assembly/compose.js.map +1 -1
- package/dist/assembly/delegation-registry.js +3 -14
- package/dist/assembly/delegation-registry.js.map +1 -1
- package/dist/assembly/index.d.ts +8 -15
- package/dist/assembly/index.js +21 -28
- package/dist/assembly/index.js.map +1 -1
- package/dist/assembly/plain.js +1 -2
- package/dist/assembly/plain.js.map +1 -1
- package/dist/authoring-skill/archmax-harness/README.md +5 -5
- package/dist/authoring-skill/archmax-harness/SKILL.md +72 -30
- package/dist/authoring-skill/archmax-harness/references/backend-integration.md +33 -24
- package/dist/authoring-skill/archmax-harness/references/cases.md +41 -8
- package/dist/authoring-skill/archmax-harness/references/{hook-and-test-scripts.md → code-state-and-test-scripts.md} +599 -339
- package/dist/authoring-skill/archmax-harness/references/code-states-and-scripts.md +115 -0
- package/dist/authoring-skill/archmax-harness/references/diagnostics.md +40 -7
- package/dist/authoring-skill/archmax-harness/references/wiring.md +19 -10
- package/dist/authoring-skill/archmax-harness/references/workflow-schema.md +404 -293
- package/dist/authoring-skill/archmax-harness/references/workflow-yaml.md +151 -62
- package/dist/cli/state-flow.d.ts +1 -1
- package/dist/cli/state-flow.js +18 -28
- package/dist/cli/state-flow.js.map +1 -1
- package/dist/cli/turn.d.ts +1 -1
- package/dist/cli/turn.js +1 -1
- package/dist/core/code-description.d.ts +3 -3
- package/dist/core/code-description.js +3 -3
- package/dist/core/deepagents.d.ts +5 -12
- package/dist/core/deepagents.js +4 -17
- package/dist/core/deepagents.js.map +1 -1
- package/dist/core/events.d.ts +23 -42
- package/dist/core/events.js +21 -24
- package/dist/core/events.js.map +1 -1
- package/dist/core/message-readers.d.ts +4 -5
- package/dist/core/message-readers.js +3 -8
- package/dist/core/message-readers.js.map +1 -1
- package/dist/core/messages.d.ts +0 -22
- package/dist/core/messages.js +1 -32
- package/dist/core/messages.js.map +1 -1
- package/dist/core/mounts.js +3 -3
- package/dist/core/platform-prompt.generated.js +1 -1
- package/dist/core/platform-prompt.generated.js.map +1 -1
- package/dist/core/session-zone.d.ts +1 -1
- package/dist/core/session-zone.js +1 -1
- package/dist/core/workspace-context.d.ts +1 -1
- package/dist/core/workspace.d.ts +1 -1
- package/dist/core/workspace.js +1 -1
- package/dist/core/zones.d.ts +4 -4
- package/dist/core/zones.js +5 -5
- package/dist/core/zones.js.map +1 -1
- package/dist/env.d.ts +9 -9
- package/dist/index.d.ts +3 -7
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist/kernel/kernel.d.ts +31 -61
- package/dist/kernel/kernel.js +54 -112
- package/dist/kernel/kernel.js.map +1 -1
- package/dist/machine/lint-spec.js +53 -12
- package/dist/machine/lint-spec.js.map +1 -1
- package/dist/machine/machine.d.ts +36 -18
- package/dist/machine/machine.js +62 -51
- package/dist/machine/machine.js.map +1 -1
- package/dist/machine/spec-schema.d.ts +32 -180
- package/dist/machine/spec-schema.js +52 -113
- package/dist/machine/spec-schema.js.map +1 -1
- package/dist/machine/tool-names.d.ts +34 -16
- package/dist/machine/tool-names.js +41 -16
- package/dist/machine/tool-names.js.map +1 -1
- package/dist/machine/types.d.ts +14 -46
- package/dist/machine/types.js +0 -2
- package/dist/machine/types.js.map +1 -1
- package/dist/machine/validate-spec.d.ts +1 -1
- package/dist/public/sandbox.d.ts +59 -95
- package/dist/public/sandbox.js +22 -23
- package/dist/public/sandbox.js.map +1 -1
- package/dist/public/spec.d.ts +13 -20
- package/dist/public/spec.js +12 -20
- package/dist/public/spec.js.map +1 -1
- package/dist/runtime/contract.d.ts +11 -12
- package/dist/runtime/contract.js +16 -16
- package/dist/runtime/contract.js.map +1 -1
- package/dist/sandbox/assets/parts/code-state.js +17 -0
- package/dist/sandbox/executor.d.ts +25 -7
- package/dist/sandbox/executor.js +56 -57
- package/dist/sandbox/executor.js.map +1 -1
- package/dist/sandbox/imports.d.ts +10 -10
- package/dist/sandbox/imports.js +11 -11
- package/dist/sandbox/imports.js.map +1 -1
- package/dist/sandbox/prelude.d.ts +5 -6
- package/dist/sandbox/prelude.js +38 -35
- package/dist/sandbox/prelude.js.map +1 -1
- package/dist/sandbox/ptc-gateway.d.ts +19 -18
- package/dist/sandbox/ptc-gateway.js +26 -22
- package/dist/sandbox/ptc-gateway.js.map +1 -1
- package/dist/sessions/resume.d.ts +2 -2
- package/dist/sessions/resume.js +1 -1
- package/dist/sessions/resume.js.map +1 -1
- package/dist/sessions/scope.d.ts +0 -10
- package/dist/sessions/scope.js +0 -17
- package/dist/sessions/scope.js.map +1 -1
- package/dist/sessions/summary.d.ts +1 -1
- package/dist/testing/assertions.js +9 -4
- package/dist/testing/assertions.js.map +1 -1
- package/dist/testing/driver.js +3 -0
- package/dist/testing/driver.js.map +1 -1
- package/dist/testing/interpreter.d.ts +2 -2
- package/dist/testing/runner.d.ts +2 -2
- package/dist/validate/validate.d.ts +1 -1
- package/dist/validate/validate.js +39 -70
- package/dist/validate/validate.js.map +1 -1
- package/dist/workflow/automated-controls.d.ts +63 -0
- package/dist/workflow/automated-controls.js +158 -0
- package/dist/workflow/automated-controls.js.map +1 -0
- package/dist/workflow/automated.d.ts +112 -0
- package/dist/workflow/automated.js +163 -0
- package/dist/workflow/automated.js.map +1 -0
- package/dist/workflow/code-state.d.ts +46 -0
- package/dist/workflow/code-state.js +26 -0
- package/dist/workflow/code-state.js.map +1 -0
- package/dist/workflow/control-tools.d.ts +54 -23
- package/dist/workflow/control-tools.js +99 -79
- package/dist/workflow/control-tools.js.map +1 -1
- package/dist/workflow/file-values.d.ts +4 -4
- package/dist/workflow/file-values.js +1 -1
- package/dist/workflow/file-values.js.map +1 -1
- package/dist/workflow/governance.d.ts +11 -22
- package/dist/workflow/governance.js +47 -104
- package/dist/workflow/governance.js.map +1 -1
- package/dist/workflow/grader-state.d.ts +55 -0
- package/dist/workflow/grader-state.js +182 -0
- package/dist/workflow/grader-state.js.map +1 -0
- package/dist/workflow/history.d.ts +11 -0
- package/dist/{lifecycle/transcript.js → workflow/history.js} +24 -8
- package/dist/workflow/history.js.map +1 -0
- package/dist/workflow/middleware.d.ts +14 -17
- package/dist/workflow/middleware.js +109 -95
- package/dist/workflow/middleware.js.map +1 -1
- package/dist/workflow/move-events.d.ts +21 -0
- package/dist/workflow/move-events.js +20 -0
- package/dist/workflow/move-events.js.map +1 -0
- package/dist/workflow/on-error.js +0 -2
- package/dist/workflow/on-error.js.map +1 -1
- package/dist/workflow/parks.d.ts +9 -2
- package/dist/workflow/parks.js +16 -10
- package/dist/workflow/parks.js.map +1 -1
- package/dist/workflow/paths.d.ts +9 -9
- package/dist/workflow/paths.js +19 -19
- package/dist/workflow/paths.js.map +1 -1
- package/dist/workflow/render-prompt.d.ts +7 -5
- package/dist/workflow/render-prompt.js +22 -37
- package/dist/workflow/render-prompt.js.map +1 -1
- package/dist/workflow/signature-checks.d.ts +2 -2
- package/dist/workflow/snapshot.js +5 -29
- package/dist/workflow/snapshot.js.map +1 -1
- package/dist/workflow/state.d.ts +14 -42
- package/dist/workflow/state.js +20 -33
- package/dist/workflow/state.js.map +1 -1
- package/dist/workflow/sub-workflow.d.ts +3 -3
- package/dist/workflow/sub-workflow.js +3 -7
- package/dist/workflow/sub-workflow.js.map +1 -1
- package/dist/workflow/tool-service.d.ts +1 -9
- package/dist/workflow/tool-service.js +21 -24
- package/dist/workflow/tool-service.js.map +1 -1
- package/dist/workflow/turn-boundary.d.ts +2 -2
- package/dist/workflow/turn-boundary.js +10 -15
- package/dist/workflow/turn-boundary.js.map +1 -1
- package/dist/workflow/turn-runner.js +5 -6
- package/dist/workflow/turn-runner.js.map +1 -1
- package/package.json +1 -1
- package/skills/archmax-harness/README.md +5 -5
- package/skills/archmax-harness/SKILL.md +72 -30
- package/skills/archmax-harness/references/backend-integration.md +33 -24
- package/skills/archmax-harness/references/cases.md +41 -8
- package/skills/archmax-harness/references/{hook-and-test-scripts.md → code-state-and-test-scripts.md} +599 -339
- package/skills/archmax-harness/references/code-states-and-scripts.md +115 -0
- package/skills/archmax-harness/references/diagnostics.md +40 -7
- package/skills/archmax-harness/references/wiring.md +19 -10
- package/skills/archmax-harness/references/workflow-schema.md +404 -293
- package/skills/archmax-harness/references/workflow-yaml.md +151 -62
- package/dist/authoring-skill/archmax-harness/references/hooks-and-scripts.md +0 -89
- package/dist/lifecycle/hook-shape.d.ts +0 -44
- package/dist/lifecycle/hook-shape.js +0 -66
- package/dist/lifecycle/hook-shape.js.map +0 -1
- package/dist/lifecycle/runner.d.ts +0 -197
- package/dist/lifecycle/runner.js +0 -419
- package/dist/lifecycle/runner.js.map +0 -1
- package/dist/lifecycle/tool-calls.d.ts +0 -9
- package/dist/lifecycle/tool-calls.js +0 -57
- package/dist/lifecycle/tool-calls.js.map +0 -1
- package/dist/lifecycle/transcript.d.ts +0 -31
- package/dist/lifecycle/transcript.js.map +0 -1
- package/dist/rubrics/rubrics.d.ts +0 -135
- package/dist/rubrics/rubrics.js +0 -145
- package/dist/rubrics/rubrics.js.map +0 -1
- package/dist/sandbox/assets/parts/core.js +0 -22
- package/dist/sandbox/assets/parts/lifecycle-hook.js +0 -47
- package/dist/sandbox/bridge.d.ts +0 -16
- package/dist/sandbox/bridge.js +0 -95
- package/dist/sandbox/bridge.js.map +0 -1
- package/dist/workflow/visits.d.ts +0 -21
- package/dist/workflow/visits.js +0 -45
- package/dist/workflow/visits.js.map +0 -1
- package/skills/archmax-harness/references/hooks-and-scripts.md +0 -89
package/dist/env.d.ts
CHANGED
|
@@ -66,11 +66,11 @@ export declare function loadPromptCacheEnv(): {
|
|
|
66
66
|
*/
|
|
67
67
|
export declare function loadPricingEnv(): PricingTable | undefined;
|
|
68
68
|
/**
|
|
69
|
-
* The role a model plays in the runtime: the workflow `agent` (
|
|
70
|
-
* (the offline case grader), or a `
|
|
71
|
-
*
|
|
69
|
+
* The role a model plays in the runtime: the workflow `agent` (the session's
|
|
70
|
+
* turns), a `judge` (the offline case grader), or a `grader` (a grader state's
|
|
71
|
+
* subagent). A {@link ModelFactory} may return a different model per role.
|
|
72
72
|
*/
|
|
73
|
-
export type ModelRole = "agent" | "judge" | "
|
|
73
|
+
export type ModelRole = "agent" | "judge" | "grader";
|
|
74
74
|
/**
|
|
75
75
|
* Supplies the chat model for a given role, so library users can run the runtime
|
|
76
76
|
* against any LangChain `BaseChatModel` (e.g. Amazon Bedrock via
|
|
@@ -86,11 +86,11 @@ export type ModelRole = "agent" | "judge" | "rubric";
|
|
|
86
86
|
*/
|
|
87
87
|
export type ModelFactory = (role: ModelRole, env: () => AgentEnv,
|
|
88
88
|
/**
|
|
89
|
-
* The model id the caller asked for —
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* request. The default factory applies it over `ARCHMAX_MODEL`,
|
|
93
|
-
* configured endpoint and credentials.
|
|
89
|
+
* The model id the caller asked for — the `model` a state declares (or its
|
|
90
|
+
* workflow's `settings.model`), for the `agent` and `grader` roles. Additive: a
|
|
91
|
+
* factory that ignores it returns its own model, and no error is raised for an
|
|
92
|
+
* unhonoured request. The default factory applies it over `ARCHMAX_MODEL`,
|
|
93
|
+
* keeping the configured endpoint and credentials.
|
|
94
94
|
*/
|
|
95
95
|
requested?: string) => BaseChatModel;
|
|
96
96
|
/** The default, role-independent model factory: the env-configured `ChatOpenAI`. */
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* is here because a real consumer needs it, not because a module happened to
|
|
14
14
|
* expose it. Adjacent surfaces live on their own subpaths — `@archmax-ai/harness/testing`
|
|
15
15
|
* (the case engine), `@archmax-ai/harness/cli` (the state-flow renderer), and
|
|
16
|
-
* `@archmax-ai/harness/sandbox` (
|
|
16
|
+
* `@archmax-ai/harness/sandbox` (code-state script authoring) — so a production import never
|
|
17
17
|
* pulls in test machinery.
|
|
18
18
|
*
|
|
19
19
|
* Two **light** subpaths mirror part of this surface without the runtime behind
|
|
@@ -200,7 +200,7 @@ export { isAiMessage } from "./core/messages.js";
|
|
|
200
200
|
export { lastAgentText } from "./core/messages.js";
|
|
201
201
|
/**
|
|
202
202
|
* Whether the runtime wrote a transcript message rather than a person — a
|
|
203
|
-
* decision, an arrival, an error route,
|
|
203
|
+
* decision, an arrival, an error route, an automated state's move, a child's result.
|
|
204
204
|
* A host slicing a turn out of a session's messages, or rendering a transcript,
|
|
205
205
|
* asks this instead of inferring authorship from role.
|
|
206
206
|
*/
|
|
@@ -208,16 +208,12 @@ export { isRuntimeNote } from "./core/messages.js";
|
|
|
208
208
|
/** Which kind of runtime note a message is, or `null` if a person wrote it. */
|
|
209
209
|
export { runtimeNoteKind } from "./core/messages.js";
|
|
210
210
|
export type { RuntimeNoteKind } from "./core/messages.js";
|
|
211
|
-
/**
|
|
212
|
-
export type { RubricDeclaration } from "./machine/types.js";
|
|
213
|
-
/** Host data the runtime never reads, at the spec root, on a state, or on a rubric. */
|
|
211
|
+
/** Host data the runtime never reads, at the spec root or on a state. */
|
|
214
212
|
export type { SpecMetadata } from "./machine/types.js";
|
|
215
213
|
/** Parse a sandbox script's leading description block. */
|
|
216
214
|
export { parseCodeDescription } from "./core/code-description.js";
|
|
217
215
|
/** Load and shape-check a `workflow.yaml` without assembling an agent. */
|
|
218
216
|
export { loadMachineSpec } from "./machine/load-spec.js";
|
|
219
|
-
/** A `before:`/`after:` declaration as a flat list of hooks. */
|
|
220
|
-
export { normalizeHooks } from "./lifecycle/hook-shape.js";
|
|
221
217
|
export type { MachineSpec, MachineState } from "./machine/types.js";
|
|
222
218
|
/** The compiled machine, as `agent.workflow.machine` exposes it. */
|
|
223
219
|
export { WorkflowMachine } from "./machine/machine.js";
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* is here because a real consumer needs it, not because a module happened to
|
|
14
14
|
* expose it. Adjacent surfaces live on their own subpaths — `@archmax-ai/harness/testing`
|
|
15
15
|
* (the case engine), `@archmax-ai/harness/cli` (the state-flow renderer), and
|
|
16
|
-
* `@archmax-ai/harness/sandbox` (
|
|
16
|
+
* `@archmax-ai/harness/sandbox` (code-state script authoring) — so a production import never
|
|
17
17
|
* pulls in test machinery.
|
|
18
18
|
*
|
|
19
19
|
* Two **light** subpaths mirror part of this surface without the runtime behind
|
|
@@ -134,7 +134,7 @@ export { isAiMessage } from "./core/messages.js";
|
|
|
134
134
|
export { lastAgentText } from "./core/messages.js";
|
|
135
135
|
/**
|
|
136
136
|
* Whether the runtime wrote a transcript message rather than a person — a
|
|
137
|
-
* decision, an arrival, an error route,
|
|
137
|
+
* decision, an arrival, an error route, an automated state's move, a child's result.
|
|
138
138
|
* A host slicing a turn out of a session's messages, or rendering a transcript,
|
|
139
139
|
* asks this instead of inferring authorship from role.
|
|
140
140
|
*/
|
|
@@ -146,8 +146,6 @@ export { parseCodeDescription } from "./core/code-description.js";
|
|
|
146
146
|
// --- The machine --------------------------------------------------------------
|
|
147
147
|
/** Load and shape-check a `workflow.yaml` without assembling an agent. */
|
|
148
148
|
export { loadMachineSpec } from "./machine/load-spec.js";
|
|
149
|
-
/** A `before:`/`after:` declaration as a flat list of hooks. */
|
|
150
|
-
export { normalizeHooks } from "./lifecycle/hook-shape.js";
|
|
151
149
|
/** The compiled machine, as `agent.workflow.machine` exposes it. */
|
|
152
150
|
export { WorkflowMachine } from "./machine/machine.js";
|
|
153
151
|
/** Statically validate a workflow scaffold — no model calls. */
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,iFAAiF;AAEjF;;;;;GAKG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,qDAAqD;AACrD,OA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AAE,MAAM,iBAAiB,CAAC;AACrD,yDAAyD;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,iFAAiF;AACjF,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,+CAA+C;AAE/C,8DAA8D;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO;AACL;;;GAGG;AACH,2BAA2B,GAC5B,MAAM,UAAU,CAAC;AAClB,8DAA8D;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/kernel/kernel.d.ts
CHANGED
|
@@ -3,14 +3,13 @@ import type { ForbidEntry } from "../machine/types.js";
|
|
|
3
3
|
import type { VariableStore } from "../machine/variables.js";
|
|
4
4
|
import { type MountPrefixes } from "../core/mounts.js";
|
|
5
5
|
import { type SkillPrefixes } from "../core/skills.js";
|
|
6
|
-
import type { LifecycleDecision } from "../lifecycle/runner.js";
|
|
7
6
|
/**
|
|
8
7
|
* The decision kernel: a single pure, synchronous function that produces every
|
|
9
8
|
* governance verdict from the machine spec, a snapshot of checkpointed workflow
|
|
10
|
-
* state, and a proposed action
|
|
11
|
-
*
|
|
12
|
-
* kernel
|
|
13
|
-
* code path.
|
|
9
|
+
* state, and a proposed action — a tool call or a transition. Effectful work
|
|
10
|
+
* (running a code state's script, a grader) happens elsewhere and asks the
|
|
11
|
+
* kernel about each call and move it makes, so runtime enforcement and static
|
|
12
|
+
* validation share one code path.
|
|
14
13
|
*/
|
|
15
14
|
export type VerdictDecision = "allow" | "block";
|
|
16
15
|
export interface Verdict {
|
|
@@ -28,38 +27,22 @@ export interface Verdict {
|
|
|
28
27
|
reason?: string;
|
|
29
28
|
/** Tool-call blocks: whether the block should surface as a warn-level event. */
|
|
30
29
|
warn?: boolean;
|
|
31
|
-
/** Transition reductions: whether the deciding hook consumed one of its iterations. */
|
|
32
|
-
correctionConsumed?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Transition reductions: whether the block is a `correct` refused because the
|
|
35
|
-
* hook's `max_iterations` are already spent. Retrying in place cannot clear
|
|
36
|
-
* it, so the runner reports it as a terminal rejection.
|
|
37
|
-
*/
|
|
38
|
-
budgetExhausted?: boolean;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* A reduced lifecycle-hook outcome. `LifecycleRunner` executes a hook, parses
|
|
42
|
-
* its return value into a {@link LifecycleDecision}, and hands it here (with an
|
|
43
|
-
* optional `error` when the hook could not execute) for reduction.
|
|
44
|
-
*/
|
|
45
|
-
export interface HookFact extends LifecycleDecision {
|
|
46
|
-
/** Present when the hook could not execute; reduces to a fail-closed veto. */
|
|
47
|
-
error?: string;
|
|
48
|
-
/** Bounded grade-and-retry budget for an `after` hook of any kind (0 = none). */
|
|
49
|
-
maxIterations?: number;
|
|
50
|
-
/** Iterations already consumed for this state. */
|
|
51
|
-
iterationsUsed?: number;
|
|
52
30
|
}
|
|
53
31
|
/**
|
|
54
|
-
* Who initiated a tool call
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
32
|
+
* Who initiated a tool call, which decides the authority it runs on:
|
|
33
|
+
*
|
|
34
|
+
* - `agent` (the default): a model's call — the session's agent in an agent
|
|
35
|
+
* state, the grader in a grader state;
|
|
36
|
+
* - `script`: a programmatic call from a sandbox script — the agent's
|
|
37
|
+
* `archmax_eval`/`archmax_run`, or a code state's script — governed exactly as
|
|
38
|
+
* a model's call in the same state;
|
|
39
|
+
* - `runtime`: the runtime's own read of a `file` value, on runtime authority:
|
|
40
|
+
* outside the active state's surface — its allow and forbid lists, its skill
|
|
41
|
+
* and mount grants — but held to its workflow's mount grants, its
|
|
42
|
+
* workflow-wide denials and every safety rule. No script or model ever runs
|
|
43
|
+
* on it.
|
|
61
44
|
*/
|
|
62
|
-
export type ToolCallOrigin = "agent" | "script" | "
|
|
45
|
+
export type ToolCallOrigin = "agent" | "script" | "runtime";
|
|
63
46
|
export type ProposedAction = {
|
|
64
47
|
kind: "tool-call";
|
|
65
48
|
state: string;
|
|
@@ -78,12 +61,9 @@ export type ProposedAction = {
|
|
|
78
61
|
from: string;
|
|
79
62
|
to: string;
|
|
80
63
|
reason?: string;
|
|
81
|
-
hookFacts: HookFact[];
|
|
82
|
-
} | {
|
|
83
|
-
kind: "enter-state";
|
|
84
|
-
state: string;
|
|
85
|
-
hookFacts: HookFact[];
|
|
86
64
|
};
|
|
65
|
+
/** The variables a state still owes before it may be left — its `requires` minus what is set. */
|
|
66
|
+
export declare function unmetRequirements(required: string[], store: VariableStore): string[];
|
|
87
67
|
/** Read-only context a governance rule may consult. */
|
|
88
68
|
export interface RuleApi {
|
|
89
69
|
machine: WorkflowMachine;
|
|
@@ -113,10 +93,13 @@ export interface RuleApi {
|
|
|
113
93
|
*/
|
|
114
94
|
export type GovernanceRule = (action: ProposedAction, api: RuleApi) => Verdict | null;
|
|
115
95
|
/**
|
|
116
|
-
*
|
|
117
|
-
* (PTC): every harness control tool
|
|
118
|
-
* sandboxed code cannot re-enter the
|
|
119
|
-
*
|
|
96
|
+
* Tools an **agent state's** scripts (`archmax_eval`, `archmax_run`) may never
|
|
97
|
+
* invoke through programmatic tool calling (PTC): every harness control tool
|
|
98
|
+
* (including both sandbox entry points, so sandboxed code cannot re-enter the
|
|
99
|
+
* sandbox) plus a bare `eval`. Moving the machine and writing its variables is
|
|
100
|
+
* the model's own governed decision there; the script reads the variables via
|
|
101
|
+
* `args.variables`. A code state is the exception by construction: its script
|
|
102
|
+
* *is* the state, so it is handed its state's controls as its own tools.
|
|
120
103
|
*/
|
|
121
104
|
export declare const PTC_EXCLUDED_TOOLS: ReadonlySet<string>;
|
|
122
105
|
/**
|
|
@@ -125,19 +108,6 @@ export declare const PTC_EXCLUDED_TOOLS: ReadonlySet<string>;
|
|
|
125
108
|
* `core/zones.ts` so runtime, mount routing, and validation agree.
|
|
126
109
|
*/
|
|
127
110
|
export declare function isReadOnlyZonePath(path: string, mounts?: MountPrefixes): boolean;
|
|
128
|
-
/**
|
|
129
|
-
* Reduce a single lifecycle-hook fact to a verdict. Fail-closed: an execution
|
|
130
|
-
* error is a veto. `before` hooks gate entry with `ok`/`veto` only — a `correct`
|
|
131
|
-
* at entry has nothing to retry, so it reduces to a veto and never consumes the
|
|
132
|
-
* correction budget. Within an `after` veto window any hook's `correct` (script
|
|
133
|
-
* or subagent judge alike) enters the same bounded correction flow, budgeted by
|
|
134
|
-
* the hook's `max_corrections`.
|
|
135
|
-
*/
|
|
136
|
-
export declare function reduceHookFact(fact: HookFact, opts: {
|
|
137
|
-
phase: "before" | "after" | "tool";
|
|
138
|
-
veto: boolean;
|
|
139
|
-
to?: string;
|
|
140
|
-
}): Verdict;
|
|
141
111
|
/**
|
|
142
112
|
* An **ancestor's** `mounts.forbid_always`, as rules the descendant inherits.
|
|
143
113
|
* The mount twin of {@link compileForbiddenSkillRules}: a child machine resolves
|
|
@@ -145,8 +115,8 @@ export declare function reduceHookFact(fact: HookFact, opts: {
|
|
|
145
115
|
* a rule — any path under one of those mounts is refused, whatever the child
|
|
146
116
|
* granted itself, and the refusal names the workflow that denied it.
|
|
147
117
|
*
|
|
148
|
-
* A workflow-wide denial binds
|
|
149
|
-
*
|
|
118
|
+
* A workflow-wide denial binds the runtime's own reads too, so this rule binds
|
|
119
|
+
* the `runtime` origin as well.
|
|
150
120
|
*/
|
|
151
121
|
export declare function compileForbiddenMountRules(names: readonly string[], source: string): GovernanceRule[];
|
|
152
122
|
/**
|
|
@@ -154,9 +124,9 @@ export declare function compileForbiddenMountRules(names: readonly string[], sou
|
|
|
154
124
|
* `tools.forbid_always`, `skills.forbid_always` and `mounts.forbid_always`,
|
|
155
125
|
* named with the workflow that declared them. A per-state `forbid` is not
|
|
156
126
|
* inherited — it governs that state's turns, not a child session — and neither
|
|
157
|
-
* is any grant. Compiled as rules, they bind
|
|
158
|
-
*
|
|
159
|
-
* them.
|
|
127
|
+
* is any grant. Compiled as rules, they bind every origin, so a descendant's
|
|
128
|
+
* automated states and the runtime's reads on a child's behalf are held to
|
|
129
|
+
* them.
|
|
160
130
|
*/
|
|
161
131
|
export declare function workflowDenials(machine: WorkflowMachine, source: string): GovernanceRule[];
|
|
162
132
|
/**
|
package/dist/kernel/kernel.js
CHANGED
|
@@ -2,31 +2,33 @@ import { ADVANCE_TOOL, DEFAULT_TOOLS, HARNESS_CONTROL_TOOLS, EVAL_TOOL, SET_VARI
|
|
|
2
2
|
import { FORBID_ANY_TOOL } from "../machine/spec-schema.js";
|
|
3
3
|
import { argsSatisfy, normalizeAllowEntry, pathGuardMatches, } from "../machine/allow.js";
|
|
4
4
|
import { BUILT_IN_TOOL_PATH_TABLE, declaredPathsOf, malformedPathArgs, MUTATING_ACCESSES, OFFLOAD_ACCESSES, pathArgNamesOf, pathValuesOf, SCRATCHPAD_ACCESSES, } from "../machine/tool-paths.js";
|
|
5
|
-
import { unmetRequirements } from "../workflow/control-tools.js";
|
|
6
5
|
import { canonicalizeRelPath } from "../core/workspace.js";
|
|
7
6
|
import { classifyWorkspacePath, mountNameOf, SESSION_INTERNAL_DIRS, SESSION_OFFLOAD_DIRS, SESSION_OPEN_DIR, } from "../core/zones.js";
|
|
8
7
|
import { NO_MOUNTS } from "../core/mounts.js";
|
|
9
8
|
import { NO_SKILLS, skillOfPath } from "../core/skills.js";
|
|
10
9
|
import { authoringPlanePrefix, describeAuthoringPrefix } from "../core/mounts.js";
|
|
11
|
-
|
|
10
|
+
/** The variables a state still owes before it may be left — its `requires` minus what is set. */
|
|
11
|
+
export function unmetRequirements(required, store) {
|
|
12
|
+
return required.filter((name) => store[name] === undefined);
|
|
13
|
+
}
|
|
12
14
|
/**
|
|
13
|
-
*
|
|
14
|
-
* (PTC): every harness control tool
|
|
15
|
-
* sandboxed code cannot re-enter the
|
|
16
|
-
*
|
|
15
|
+
* Tools an **agent state's** scripts (`archmax_eval`, `archmax_run`) may never
|
|
16
|
+
* invoke through programmatic tool calling (PTC): every harness control tool
|
|
17
|
+
* (including both sandbox entry points, so sandboxed code cannot re-enter the
|
|
18
|
+
* sandbox) plus a bare `eval`. Moving the machine and writing its variables is
|
|
19
|
+
* the model's own governed decision there; the script reads the variables via
|
|
20
|
+
* `args.variables`. A code state is the exception by construction: its script
|
|
21
|
+
* *is* the state, so it is handed its state's controls as its own tools.
|
|
17
22
|
*/
|
|
18
23
|
export const PTC_EXCLUDED_TOOLS = new Set([
|
|
19
|
-
// Moving the state machine is the model's governed decision, and a script
|
|
20
|
-
// that could *write* variables would be editing the governance inputs of the
|
|
21
|
-
// state it judges (scripts read them via the `args.variables` snapshot).
|
|
22
24
|
...HARNESS_CONTROL_TOOLS,
|
|
23
25
|
"eval",
|
|
24
26
|
]);
|
|
25
27
|
const EVAL_BLOCK_MESSAGE = `[workflow] BLOCKED: an unnamespaced \`eval\` tool is never governed — use ` +
|
|
26
28
|
`\`${EVAL_TOOL}\`, the runtime's own code interpreter.`;
|
|
27
|
-
const TASK_BLOCK_MESSAGE = `[workflow] BLOCKED: \`task\` is
|
|
28
|
-
`
|
|
29
|
-
`
|
|
29
|
+
const TASK_BLOCK_MESSAGE = `[workflow] BLOCKED: \`task\` is Deep Agents' subagent dispatch, not a tool a state may call. ` +
|
|
30
|
+
`To delegate work to another process, use the workflow's declared \`archmax_workflow_<slug>\` ` +
|
|
31
|
+
`tool; work is graded by a grader state the workflow declares, never by you.`;
|
|
30
32
|
const ALLOW = { decision: "allow", ruleId: "allow" };
|
|
31
33
|
/**
|
|
32
34
|
* The workspace paths a call names, from the tool's declared path arguments
|
|
@@ -70,64 +72,6 @@ function normalizeZonePath(path) {
|
|
|
70
72
|
export function isReadOnlyZonePath(path, mounts) {
|
|
71
73
|
return classifyWorkspacePath(path, mounts) === "authored";
|
|
72
74
|
}
|
|
73
|
-
/**
|
|
74
|
-
* Reduce a single lifecycle-hook fact to a verdict. Fail-closed: an execution
|
|
75
|
-
* error is a veto. `before` hooks gate entry with `ok`/`veto` only — a `correct`
|
|
76
|
-
* at entry has nothing to retry, so it reduces to a veto and never consumes the
|
|
77
|
-
* correction budget. Within an `after` veto window any hook's `correct` (script
|
|
78
|
-
* or subagent judge alike) enters the same bounded correction flow, budgeted by
|
|
79
|
-
* the hook's `max_corrections`.
|
|
80
|
-
*/
|
|
81
|
-
export function reduceHookFact(fact, opts) {
|
|
82
|
-
if (fact.error != null) {
|
|
83
|
-
return { decision: "block", ruleId: "hook.error", reason: fact.error };
|
|
84
|
-
}
|
|
85
|
-
if (fact.verdict === "ok")
|
|
86
|
-
return { decision: "allow", ruleId: "hook.ok" };
|
|
87
|
-
if (opts.phase === "before") {
|
|
88
|
-
const reason = fact.verdict === "correct"
|
|
89
|
-
? `before hooks cannot request corrections ('correct' gates nothing at entry, treated as veto): ${fact.reason}`
|
|
90
|
-
: fact.reason;
|
|
91
|
-
return { decision: "block", ruleId: "hook.veto", reason };
|
|
92
|
-
}
|
|
93
|
-
if (opts.phase === "after" && opts.veto) {
|
|
94
|
-
const outcome = rubricTransitionOutcome(fact, {
|
|
95
|
-
maxIterations: fact.maxIterations ?? 0,
|
|
96
|
-
iterationsUsed: fact.iterationsUsed ?? 0,
|
|
97
|
-
to: opts.to,
|
|
98
|
-
});
|
|
99
|
-
if (outcome.reason) {
|
|
100
|
-
return {
|
|
101
|
-
decision: "block",
|
|
102
|
-
ruleId: fact.rubric ? "hook.rubric" : "hook.veto",
|
|
103
|
-
reason: outcome.reason,
|
|
104
|
-
// Only a block that actually granted a retry spends one, and only a
|
|
105
|
-
// `correct` refused for want of budget is unretryable.
|
|
106
|
-
correctionConsumed: outcome.consumesIteration,
|
|
107
|
-
budgetExhausted: outcome.budgetExhausted,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
return { decision: "allow", ruleId: fact.rubric ? "hook.rubric" : "hook.ok" };
|
|
111
|
-
}
|
|
112
|
-
if (opts.veto) {
|
|
113
|
-
return {
|
|
114
|
-
decision: "block",
|
|
115
|
-
ruleId: "hook.veto",
|
|
116
|
-
reason: fact.reason,
|
|
117
|
-
correctionConsumed: false,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
return { decision: "allow", ruleId: "hook.noop" };
|
|
121
|
-
}
|
|
122
|
-
/** Reduce an ordered list of hook facts, short-circuiting on the first block. */
|
|
123
|
-
function reduceHookFacts(facts, opts) {
|
|
124
|
-
for (const fact of facts) {
|
|
125
|
-
const verdict = reduceHookFact(fact, opts);
|
|
126
|
-
if (verdict.decision !== "allow")
|
|
127
|
-
return verdict;
|
|
128
|
-
}
|
|
129
|
-
return ALLOW;
|
|
130
|
-
}
|
|
131
75
|
/** The `not allowed in this state` block verdict shared by the tool-governance rules. */
|
|
132
76
|
function notAllowedVerdict(machine, state, tool, args) {
|
|
133
77
|
const target = typeof args.file_path === "string" ? ` on '${args.file_path}'` : "";
|
|
@@ -172,11 +116,11 @@ const evalBlockRule = (action) => {
|
|
|
172
116
|
return { decision: "block", ruleId: "tool.eval", reason: EVAL_BLOCK_MESSAGE, warn: false };
|
|
173
117
|
};
|
|
174
118
|
/**
|
|
175
|
-
* Safety rule: `task` is never callable
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
119
|
+
* Safety rule: `task` is never callable. Deep Agents registers it whatever the
|
|
120
|
+
* assembly passes; that is not a grant. Non-overridable, so no state entry,
|
|
121
|
+
* `allow_always` or consumer rule can re-open it — which is why disclosure
|
|
122
|
+
* withholding it and this rule refusing it are two independent gates on the
|
|
123
|
+
* same fact.
|
|
180
124
|
*/
|
|
181
125
|
const taskBlockRule = (action) => {
|
|
182
126
|
if (action.kind !== "tool-call" || !UNGRANTABLE_TOOLS.has(action.tool))
|
|
@@ -260,7 +204,7 @@ const runtimeManagedRule = (action, api) => {
|
|
|
260
204
|
* rules, and the per-state `allow` default, so no declaration can reach into a
|
|
261
205
|
* capability the state was not given; a `tools.allow` entry may only narrow
|
|
262
206
|
* *within* the enabled set. `script` origin is bound (model authority); a
|
|
263
|
-
* `
|
|
207
|
+
* `runtime`-origin call runs on runtime authority, outside the enabled set,
|
|
264
208
|
* and is held only to its workflow's own `skills.forbid_always`
|
|
265
209
|
* ({@link runtimeSkillVerdict}).
|
|
266
210
|
*/
|
|
@@ -270,7 +214,7 @@ const skillRule = (action, api) => {
|
|
|
270
214
|
const skills = api.skills ?? NO_SKILLS;
|
|
271
215
|
if (skills.length === 0)
|
|
272
216
|
return null;
|
|
273
|
-
const verdictOf = action.origin === "
|
|
217
|
+
const verdictOf = action.origin === "runtime" ? runtimeSkillVerdict : skillVerdict;
|
|
274
218
|
for (const path of pathsOf(action, api)) {
|
|
275
219
|
const verdict = verdictOf(action, path, api, skills);
|
|
276
220
|
if (verdict)
|
|
@@ -279,9 +223,9 @@ const skillRule = (action, api) => {
|
|
|
279
223
|
return null;
|
|
280
224
|
};
|
|
281
225
|
/**
|
|
282
|
-
* {@link skillRule} for one path of a call on runtime authority:
|
|
283
|
-
* bundle whatever the enabled set, except one its workflow's
|
|
284
|
-
* denies. A state's `skills.forbid` does not bind it.
|
|
226
|
+
* {@link skillRule} for one path of a call on runtime authority: the runtime reads
|
|
227
|
+
* any bundle whatever the enabled set, except one its workflow's
|
|
228
|
+
* `skills.forbid_always` denies. A state's `skills.forbid` does not bind it.
|
|
285
229
|
*/
|
|
286
230
|
function runtimeSkillVerdict(action, path, api, skills) {
|
|
287
231
|
const slug = skillOfPath(path.path, skills);
|
|
@@ -352,7 +296,7 @@ function skillVerdict(action, path, api, skills) {
|
|
|
352
296
|
*
|
|
353
297
|
* Evaluated after the zone rules, so a *write* into a hidden read-only mount is
|
|
354
298
|
* refused as read-only — the more useful reason — whether or not the state has
|
|
355
|
-
* the mount. Non-overridable. A `
|
|
299
|
+
* the mount. Non-overridable. A `runtime`-origin call runs on runtime
|
|
356
300
|
* authority, so it is decided on its **workflow**'s grants instead of the
|
|
357
301
|
* state's ({@link runtimeMountVerdict}): outside the state's surface, never
|
|
358
302
|
* outside the workflow's.
|
|
@@ -360,7 +304,7 @@ function skillVerdict(action, path, api, skills) {
|
|
|
360
304
|
const mountRule = (action, api) => {
|
|
361
305
|
if (action.kind !== "tool-call")
|
|
362
306
|
return null;
|
|
363
|
-
const verdictOf = action.origin === "
|
|
307
|
+
const verdictOf = action.origin === "runtime" ? runtimeMountVerdict : mountVerdict;
|
|
364
308
|
for (const path of pathsOf(action, api)) {
|
|
365
309
|
const verdict = verdictOf(action, path, api);
|
|
366
310
|
if (verdict)
|
|
@@ -371,9 +315,9 @@ const mountRule = (action, api) => {
|
|
|
371
315
|
/**
|
|
372
316
|
* {@link mountRule} for one path of a call on runtime authority. One table serves
|
|
373
317
|
* a session and every child it dispatches, so it holds mounts other workflows in
|
|
374
|
-
* the tree grant:
|
|
375
|
-
* own workflow names it, in any state, and writes it only where the
|
|
376
|
-
* asks to. The workflow's own `mounts.forbid_always` binds it; a state's
|
|
318
|
+
* the tree grant: the runtime reads a governed mount only where some grant of
|
|
319
|
+
* its own workflow names it, in any state, and writes it only where the
|
|
320
|
+
* workflow asks to. The workflow's own `mounts.forbid_always` binds it; a state's
|
|
377
321
|
* `mounts.allow`, `mounts.forbid` and `access: read` do not.
|
|
378
322
|
*/
|
|
379
323
|
function runtimeMountVerdict(action, path, api) {
|
|
@@ -396,8 +340,8 @@ function runtimeMountVerdict(action, path, api) {
|
|
|
396
340
|
decision: "block",
|
|
397
341
|
ruleId: "mount.not-allowed",
|
|
398
342
|
reason: `[workflow] BLOCKED: ${on} is under the mount '${name}', which no grant of this ` +
|
|
399
|
-
`workflow names.
|
|
400
|
-
`in 'mounts.allow_always' or a state's 'mounts.allow'.`,
|
|
343
|
+
`workflow names. The runtime reaches a governed mount only where its workflow grants ` +
|
|
344
|
+
`it, in 'mounts.allow_always' or a state's 'mounts.allow'.`,
|
|
401
345
|
warn: true,
|
|
402
346
|
};
|
|
403
347
|
}
|
|
@@ -473,8 +417,8 @@ function mountVerdict(action, path, api) {
|
|
|
473
417
|
* a rule — any path under one of those mounts is refused, whatever the child
|
|
474
418
|
* granted itself, and the refusal names the workflow that denied it.
|
|
475
419
|
*
|
|
476
|
-
* A workflow-wide denial binds
|
|
477
|
-
*
|
|
420
|
+
* A workflow-wide denial binds the runtime's own reads too, so this rule binds
|
|
421
|
+
* the `runtime` origin as well.
|
|
478
422
|
*/
|
|
479
423
|
export function compileForbiddenMountRules(names, source) {
|
|
480
424
|
if (names.length === 0)
|
|
@@ -508,9 +452,9 @@ export function compileForbiddenMountRules(names, source) {
|
|
|
508
452
|
* `tools.forbid_always`, `skills.forbid_always` and `mounts.forbid_always`,
|
|
509
453
|
* named with the workflow that declared them. A per-state `forbid` is not
|
|
510
454
|
* inherited — it governs that state's turns, not a child session — and neither
|
|
511
|
-
* is any grant. Compiled as rules, they bind
|
|
512
|
-
*
|
|
513
|
-
* them.
|
|
455
|
+
* is any grant. Compiled as rules, they bind every origin, so a descendant's
|
|
456
|
+
* automated states and the runtime's reads on a child's behalf are held to
|
|
457
|
+
* them.
|
|
514
458
|
*/
|
|
515
459
|
export function workflowDenials(machine, source) {
|
|
516
460
|
return [
|
|
@@ -606,9 +550,9 @@ const runOpenAccessRule = (action, api) => {
|
|
|
606
550
|
const stateToolsRule = (action, { machine, variables }) => {
|
|
607
551
|
if (action.kind !== "tool-call")
|
|
608
552
|
return null;
|
|
609
|
-
//
|
|
610
|
-
// bind them; every other rule in the pipeline still does.
|
|
611
|
-
if (action.origin === "
|
|
553
|
+
// The runtime's own reads run on runtime authority, so the state's grant does
|
|
554
|
+
// not bind them; every other rule in the pipeline still does.
|
|
555
|
+
if (action.origin === "runtime")
|
|
612
556
|
return null;
|
|
613
557
|
const { state, tool, args } = action;
|
|
614
558
|
let unresolved;
|
|
@@ -640,10 +584,10 @@ function unresolvedGuardVerdict(state, tool, failure) {
|
|
|
640
584
|
}
|
|
641
585
|
/**
|
|
642
586
|
* Safety rule: `archmax_run` executes only scripts that live inside a skill bundle.
|
|
643
|
-
*
|
|
644
|
-
* scripts (run
|
|
645
|
-
* agent cannot run
|
|
646
|
-
* workflow's
|
|
587
|
+
* A code state's script (run by the runtime from the authoring backend) and an
|
|
588
|
+
* agent's scripts (run from a skill bundle) are disjoint by construction: an
|
|
589
|
+
* agent cannot run a code state's script, a file it wrote into the run zone, or
|
|
590
|
+
* another workflow's scripts. Classification uses the resolved skill registry rather than a
|
|
647
591
|
* literal `skills/` string, so an empty registry blocks every `archmax_run`.
|
|
648
592
|
*
|
|
649
593
|
* Non-overridable: evaluated with the safety rules, ahead of `policy`, consumer
|
|
@@ -661,8 +605,8 @@ const scriptSkillOnlyRule = (action, api) => {
|
|
|
661
605
|
ruleId: "script.skill-only",
|
|
662
606
|
reason: `[workflow] BLOCKED: '${action.tool}' may only execute scripts that live in a skill bundle, ` +
|
|
663
607
|
`and '${path.path}' is not in one. Scripts the agent runs belong in ` +
|
|
664
|
-
`'skills/<capability>/scripts/';
|
|
665
|
-
`run by the
|
|
608
|
+
`'skills/<capability>/scripts/'; a code state's script lives in its workflow's 'scripts/' ` +
|
|
609
|
+
`and is run by the runtime, never by the agent.`,
|
|
666
610
|
warn: true,
|
|
667
611
|
};
|
|
668
612
|
};
|
|
@@ -690,14 +634,14 @@ const pathArgumentRule = (action, api) => {
|
|
|
690
634
|
* Safety rule: the authoring plane is not addressable. Every
|
|
691
635
|
* {@link AUTHORING_PREFIXES} prefix (`workflows/**`) has no route
|
|
692
636
|
* in the agent's workspace composite, so an agent read finds nothing; a
|
|
693
|
-
* **script** or **
|
|
637
|
+
* **script** or a **runtime** read naming one is told why, and which prefix. Applies in
|
|
694
638
|
* every state whatever it allows — the plane's isolation is structural, not
|
|
695
639
|
* granted.
|
|
696
640
|
*/
|
|
697
641
|
const governancePlaneRule = (action, api) => {
|
|
698
642
|
if (action.kind !== "tool-call")
|
|
699
643
|
return null;
|
|
700
|
-
if (action.origin !== "script" && action.origin !== "
|
|
644
|
+
if (action.origin !== "script" && action.origin !== "runtime")
|
|
701
645
|
return null;
|
|
702
646
|
// A tool that declares no paths is still read by its conventional path
|
|
703
647
|
// argument here: the plane's isolation does not wait on a declaration.
|
|
@@ -781,6 +725,10 @@ export function compileForbidRules(entries, options) {
|
|
|
781
725
|
return null;
|
|
782
726
|
if (scope === "state" && action.state !== state)
|
|
783
727
|
return null;
|
|
728
|
+
// A state's own denial governs that state's surface, which a read on
|
|
729
|
+
// runtime authority runs outside of; only workflow-wide denials bind it.
|
|
730
|
+
if (scope === "state" && action.origin === "runtime")
|
|
731
|
+
return null;
|
|
784
732
|
const guards = argMatchers ? describeGuards(normalized) : null;
|
|
785
733
|
if (argMatchers && !denialMatches(normalized, action, api))
|
|
786
734
|
return null;
|
|
@@ -884,8 +832,8 @@ export function decide(machine, action, customRules = [], mountPrefixes = NO_MOU
|
|
|
884
832
|
case "tool-call":
|
|
885
833
|
return decideToolCall(machine, action, customRules, mountPrefixes, variables, skills);
|
|
886
834
|
case "transition": {
|
|
887
|
-
// The `requires` gate runs before the edge
|
|
888
|
-
//
|
|
835
|
+
// The `requires` gate runs before the edge: the state owes a value it can
|
|
836
|
+
// still supply, which is the more useful refusal.
|
|
889
837
|
const unmet = unmetRequirements(machine.requiredVariables(action.from), variables ?? {});
|
|
890
838
|
if (unmet.length > 0) {
|
|
891
839
|
return {
|
|
@@ -908,14 +856,8 @@ export function decide(machine, action, customRules = [], mountPrefixes = NO_MOU
|
|
|
908
856
|
: "No transitions from this state."),
|
|
909
857
|
};
|
|
910
858
|
}
|
|
911
|
-
return
|
|
912
|
-
phase: "after",
|
|
913
|
-
veto: true,
|
|
914
|
-
to: action.to,
|
|
915
|
-
});
|
|
859
|
+
return ALLOW;
|
|
916
860
|
}
|
|
917
|
-
case "enter-state":
|
|
918
|
-
return reduceHookFacts(action.hookFacts, { phase: "before", veto: false });
|
|
919
861
|
}
|
|
920
862
|
}
|
|
921
863
|
//# sourceMappingURL=kernel.js.map
|