@mamund/grail 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +328 -2
- package/affordanceModel.js +23 -0
- package/affordanceRegistry.js +14 -0
- package/bindings/binding.js +229 -0
- package/bindings/httpBinding.js +173 -0
- package/bindings/nodeBinding.js +25 -0
- package/bindings/stdioBinding.js +58 -0
- package/cli/grail-cli.js +565 -0
- package/client.js +77 -0
- package/config-loader/loadEnvironment.js +71 -0
- package/docs/ENVIRONMENT.md +381 -0
- package/docs/grail-trust-model.md +665 -0
- package/examples/cli-tour/README.md +346 -0
- package/examples/cli-tour/capabilities/farewell.js +3 -0
- package/examples/cli-tour/capabilities/hello.js +3 -0
- package/examples/cli-tour/config/goal.json +3 -0
- package/examples/cli-tour/config/inputs.json +3 -0
- package/examples/cli-tour/config/observations.json +23 -0
- package/examples/cli-tour/config/registry.json +48 -0
- package/examples/cli-tour/config/worldstate.json +4 -0
- package/examples/cli-tour/g-loop.sh +7 -0
- package/examples/cli-tour/inputs/jane.json +3 -0
- package/examples/cli-tour/inputs/mike.json +3 -0
- package/examples/cli-tour/inputs/ruth.json +3 -0
- package/grail.js +59 -0
- package/images/grail-release-banner.png +0 -0
- package/index.js +2 -0
- package/observationStore.js +110 -0
- package/package.json +57 -4
- package/schemas/goal.schema.json +14 -0
- package/schemas/inputs.schema.json +6 -0
- package/schemas/observations.schema.json +75 -0
- package/schemas/registry.schema.json +285 -0
- package/schemas/worldstate.schema.json +7 -0
- package/server.js +201 -0
- package/utils/loadJSON.js +33 -0
- package/utils/validateWithSchema.js +42 -0
- package/worldState.js +36 -0
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
# What Is Not in the Agent Must Be in the Environment
|
|
2
|
+
|
|
3
|
+
*Notes on bounded autonomy in GRAIL*
|
|
4
|
+
|
|
5
|
+
GRAIL began with a simple change in perspective.
|
|
6
|
+
|
|
7
|
+
Instead of giving an agent a predefined workflow, GRAIL describes an
|
|
8
|
+
environment of capabilities, conditions, inputs, and effects. The agent
|
|
9
|
+
begins with a goal and acts within that environment until the goal is
|
|
10
|
+
satisfied or it determines that the goal cannot be reached with the
|
|
11
|
+
capabilities currently available.
|
|
12
|
+
|
|
13
|
+
This leads to a broader observation:
|
|
14
|
+
|
|
15
|
+
> **What is not in the agent must be in the environment.**
|
|
16
|
+
|
|
17
|
+
An autonomous system needs enough information somewhere to determine
|
|
18
|
+
what actions are possible, when those actions are possible, and what
|
|
19
|
+
changes when they succeed.
|
|
20
|
+
|
|
21
|
+
That information does not necessarily need to live inside the agent.
|
|
22
|
+
|
|
23
|
+
GRAIL deliberately puts much of it in the environment.
|
|
24
|
+
|
|
25
|
+
## Moving intelligence into the environment
|
|
26
|
+
|
|
27
|
+
Many discussions of autonomous systems focus on the intelligence of the
|
|
28
|
+
agent.
|
|
29
|
+
|
|
30
|
+
The agent is expected to understand the goal, develop a plan, choose
|
|
31
|
+
actions, interpret results, recover from failure, and determine what to
|
|
32
|
+
do next.
|
|
33
|
+
|
|
34
|
+
This naturally leads toward increasingly capable decision-making
|
|
35
|
+
systems, often involving large language models.
|
|
36
|
+
|
|
37
|
+
GRAIL takes another approach.
|
|
38
|
+
|
|
39
|
+
A GRAIL environment explicitly describes:
|
|
40
|
+
|
|
41
|
+
``` text
|
|
42
|
+
capabilities
|
|
43
|
+
conditions
|
|
44
|
+
preconditions
|
|
45
|
+
effects
|
|
46
|
+
inputs
|
|
47
|
+
bindings
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The runtime does not need to invent these relationships.
|
|
51
|
+
|
|
52
|
+
If an affordance requires:
|
|
53
|
+
|
|
54
|
+
``` text
|
|
55
|
+
customerEmailVerified
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
that requirement is declared.
|
|
59
|
+
|
|
60
|
+
If another affordance can establish:
|
|
61
|
+
|
|
62
|
+
``` text
|
|
63
|
+
customerEmailVerified
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
that possibility is also declared.
|
|
67
|
+
|
|
68
|
+
The agent does not need to understand customer onboarding well enough to
|
|
69
|
+
construct that relationship itself.
|
|
70
|
+
|
|
71
|
+
The environment already contains it.
|
|
72
|
+
|
|
73
|
+
## The environment is not a workflow
|
|
74
|
+
|
|
75
|
+
Putting more information into the environment does not mean encoding a
|
|
76
|
+
predefined route.
|
|
77
|
+
|
|
78
|
+
A workflow might say:
|
|
79
|
+
|
|
80
|
+
``` text
|
|
81
|
+
A
|
|
82
|
+
↓
|
|
83
|
+
B
|
|
84
|
+
↓
|
|
85
|
+
C
|
|
86
|
+
↓
|
|
87
|
+
D
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
A GRAIL environment instead describes relationships:
|
|
91
|
+
|
|
92
|
+
``` text
|
|
93
|
+
A establishes X
|
|
94
|
+
|
|
95
|
+
B requires X
|
|
96
|
+
B establishes Y
|
|
97
|
+
|
|
98
|
+
C also establishes Y
|
|
99
|
+
|
|
100
|
+
D requires Y
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
There may be several ways to establish a required condition.
|
|
104
|
+
|
|
105
|
+
There may be capabilities that establish several conditions at once.
|
|
106
|
+
|
|
107
|
+
A capability may fail and another capability may remain available.
|
|
108
|
+
|
|
109
|
+
The environment defines the possibilities without prescribing the path
|
|
110
|
+
through them.
|
|
111
|
+
|
|
112
|
+
This is the distinction behind:
|
|
113
|
+
|
|
114
|
+
> **Define the environment, not the path.**
|
|
115
|
+
|
|
116
|
+
The human defines the world.
|
|
117
|
+
|
|
118
|
+
The runtime traverses it.
|
|
119
|
+
|
|
120
|
+
## A small agent can still behave autonomously
|
|
121
|
+
|
|
122
|
+
Once these relationships exist in the environment, the runtime can be
|
|
123
|
+
comparatively small.
|
|
124
|
+
|
|
125
|
+
When a capability is blocked, GRAIL can identify an unmet condition.
|
|
126
|
+
|
|
127
|
+
It can discover affordances whose effects can establish that condition.
|
|
128
|
+
|
|
129
|
+
It can select one and attempt it.
|
|
130
|
+
|
|
131
|
+
If that affordance succeeds, the world changes.
|
|
132
|
+
|
|
133
|
+
If it fails, GRAIL can remove that possibility from the current pursuit
|
|
134
|
+
and select another producer when one exists.
|
|
135
|
+
|
|
136
|
+
When the goal condition becomes true, the pursuit is complete.
|
|
137
|
+
|
|
138
|
+
When a required condition remains false and no viable producer remains,
|
|
139
|
+
the pursuit cannot continue.
|
|
140
|
+
|
|
141
|
+
None of these mechanics inherently requires an LLM.
|
|
142
|
+
|
|
143
|
+
The choices can be made using simple selection algorithms.
|
|
144
|
+
|
|
145
|
+
The resulting behavior can nevertheless vary from one pursuit to another
|
|
146
|
+
because the environment may contain several valid possibilities.
|
|
147
|
+
|
|
148
|
+
This is a form of bounded autonomy.
|
|
149
|
+
|
|
150
|
+
## Bounded autonomy
|
|
151
|
+
|
|
152
|
+
GRAIL does not provide an agent with unlimited freedom.
|
|
153
|
+
|
|
154
|
+
The agent operates inside a world that humans have defined.
|
|
155
|
+
|
|
156
|
+
The registry establishes what actions are available.
|
|
157
|
+
|
|
158
|
+
Preconditions establish when those actions can occur.
|
|
159
|
+
|
|
160
|
+
Effects establish how successful actions change the world.
|
|
161
|
+
|
|
162
|
+
Bindings connect those possibilities to executable implementations.
|
|
163
|
+
|
|
164
|
+
The goal establishes the desired condition.
|
|
165
|
+
|
|
166
|
+
Within those boundaries, GRAIL can decide what to attempt as
|
|
167
|
+
circumstances change.
|
|
168
|
+
|
|
169
|
+
That distinction matters.
|
|
170
|
+
|
|
171
|
+
The system is autonomous because the path does not need to be specified
|
|
172
|
+
in advance.
|
|
173
|
+
|
|
174
|
+
The autonomy is bounded because the space of possible action has been
|
|
175
|
+
explicitly constructed.
|
|
176
|
+
|
|
177
|
+
The runtime can choose among possibilities.
|
|
178
|
+
|
|
179
|
+
It does not invent the world in which those possibilities exist.
|
|
180
|
+
|
|
181
|
+
## What the recent experiments showed
|
|
182
|
+
|
|
183
|
+
The later GRAIL experiments make this distinction increasingly visible.
|
|
184
|
+
|
|
185
|
+
Condition-based goals allow the goal to describe what should become true
|
|
186
|
+
rather than which affordance should execute.
|
|
187
|
+
|
|
188
|
+
Alternative affordances allow several capabilities to establish the same
|
|
189
|
+
condition.
|
|
190
|
+
|
|
191
|
+
Mixed bindings demonstrate that those alternatives do not need to share
|
|
192
|
+
an invocation mechanism.
|
|
193
|
+
|
|
194
|
+
Failure recovery allows a pursuit to continue after an affordance fails
|
|
195
|
+
when another viable producer remains.
|
|
196
|
+
|
|
197
|
+
Unresolvable-condition detection allows the pursuit to stop when the
|
|
198
|
+
environment no longer contains a way to establish a required condition.
|
|
199
|
+
|
|
200
|
+
Demo 24 adds stdio as another execution boundary. A capability may now
|
|
201
|
+
be implemented as an independent local process rather than as a Node
|
|
202
|
+
module or HTTP service.
|
|
203
|
+
|
|
204
|
+
None of these changes required GRAIL to understand the application
|
|
205
|
+
domain.
|
|
206
|
+
|
|
207
|
+
The runtime continues to operate on the declared structure of the
|
|
208
|
+
environment.
|
|
209
|
+
|
|
210
|
+
## The capability owns its domain
|
|
211
|
+
|
|
212
|
+
Demo 24 also exposed an important boundary.
|
|
213
|
+
|
|
214
|
+
A stdio capability can exit successfully and return valid JSON while
|
|
215
|
+
omitting an output that the binding expected to capture.
|
|
216
|
+
|
|
217
|
+
GRAIL does not reinterpret that omission as domain failure.
|
|
218
|
+
|
|
219
|
+
The process satisfied the binding contract, so the affordance succeeds
|
|
220
|
+
and its declared effects are applied.
|
|
221
|
+
|
|
222
|
+
The missing output is simply not captured.
|
|
223
|
+
|
|
224
|
+
This can be summarized as:
|
|
225
|
+
|
|
226
|
+
> **Outputs are captured data, not postconditions.**
|
|
227
|
+
|
|
228
|
+
If producing a particular value is necessary for the capability to
|
|
229
|
+
consider its work successful, the capability must make that
|
|
230
|
+
determination.
|
|
231
|
+
|
|
232
|
+
GRAIL should not inspect the returned data and attempt to infer whether
|
|
233
|
+
the domain operation really succeeded.
|
|
234
|
+
|
|
235
|
+
The application domain remains opaque to the runtime.
|
|
236
|
+
|
|
237
|
+
That boundary is another example of moving responsibility to the
|
|
238
|
+
appropriate part of the environment rather than increasing the semantic
|
|
239
|
+
intelligence of the agent.
|
|
240
|
+
|
|
241
|
+
## Bindings extend the world
|
|
242
|
+
|
|
243
|
+
The current GRAIL runtime supports three binding styles:
|
|
244
|
+
|
|
245
|
+
``` text
|
|
246
|
+
Node → local JavaScript capability
|
|
247
|
+
HTTP → network-accessible capability
|
|
248
|
+
stdio → local process capability
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
These bindings expand the set of actions that can exist in a GRAIL
|
|
252
|
+
environment.
|
|
253
|
+
|
|
254
|
+
They do not change the pursuit model.
|
|
255
|
+
|
|
256
|
+
A Python program, HTTP service, or JavaScript function can participate
|
|
257
|
+
in the same world because GRAIL cares about the affordance around the
|
|
258
|
+
implementation:
|
|
259
|
+
|
|
260
|
+
``` text
|
|
261
|
+
what conditions it requires
|
|
262
|
+
what inputs it consumes
|
|
263
|
+
what effects it establishes
|
|
264
|
+
how it can be invoked
|
|
265
|
+
what information can be observed
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
The implementation performs the work.
|
|
269
|
+
|
|
270
|
+
The environment explains how that work participates in pursuit of the
|
|
271
|
+
goal.
|
|
272
|
+
|
|
273
|
+
## Where the complexity goes
|
|
274
|
+
|
|
275
|
+
There is no claim here that GRAIL eliminates complexity.
|
|
276
|
+
|
|
277
|
+
It relocates some of it.
|
|
278
|
+
|
|
279
|
+
A system with a simpler agent requires a sufficiently expressive
|
|
280
|
+
environment.
|
|
281
|
+
|
|
282
|
+
Someone must identify the relevant conditions.
|
|
283
|
+
|
|
284
|
+
Someone must decide what capabilities exist.
|
|
285
|
+
|
|
286
|
+
Someone must declare their preconditions and effects.
|
|
287
|
+
|
|
288
|
+
Someone must implement those capabilities correctly.
|
|
289
|
+
|
|
290
|
+
Someone must decide what constitutes success.
|
|
291
|
+
|
|
292
|
+
In GRAIL, much of that work happens during composition rather than being
|
|
293
|
+
deferred to runtime reasoning.
|
|
294
|
+
|
|
295
|
+
This is the trade.
|
|
296
|
+
|
|
297
|
+
Less knowledge inside the agent requires more knowledge represented
|
|
298
|
+
outside the agent.
|
|
299
|
+
|
|
300
|
+
Or, more compactly:
|
|
301
|
+
|
|
302
|
+
> **What is not in the agent must be in the environment.**
|
|
303
|
+
|
|
304
|
+
## The role of human design
|
|
305
|
+
|
|
306
|
+
GRAIL works because a human has defined the world first.
|
|
307
|
+
|
|
308
|
+
That is not a limitation hidden by the architecture. It is one of its
|
|
309
|
+
central assumptions.
|
|
310
|
+
|
|
311
|
+
The composer decides which parts of reality matter for the goal being
|
|
312
|
+
pursued and constructs a bounded representation of them.
|
|
313
|
+
|
|
314
|
+
The resulting world is intentionally incomplete.
|
|
315
|
+
|
|
316
|
+
It does not need to describe everything that might be true.
|
|
317
|
+
|
|
318
|
+
It needs enough structure to support the goals the environment is
|
|
319
|
+
intended to make possible.
|
|
320
|
+
|
|
321
|
+
This is why the quality of a GRAIL system depends heavily on
|
|
322
|
+
composition.
|
|
323
|
+
|
|
324
|
+
Autonomy emerges inside the boundaries created by that design.
|
|
325
|
+
|
|
326
|
+
## LLMs become optional
|
|
327
|
+
|
|
328
|
+
This also changes the role an LLM might play.
|
|
329
|
+
|
|
330
|
+
An LLM can still be useful in GRAIL.
|
|
331
|
+
|
|
332
|
+
It might help select among conditions.
|
|
333
|
+
|
|
334
|
+
It might help select among affordances.
|
|
335
|
+
|
|
336
|
+
A capability invoked through HTTP, Node, or stdio might internally use
|
|
337
|
+
an LLM to perform its work.
|
|
338
|
+
|
|
339
|
+
But none of those uses requires the basic pursuit architecture itself to
|
|
340
|
+
depend on an LLM.
|
|
341
|
+
|
|
342
|
+
GRAIL therefore demonstrates something useful:
|
|
343
|
+
|
|
344
|
+
> **A meaningful level of bounded autonomy can be achieved without an
|
|
345
|
+
> LLM.**
|
|
346
|
+
|
|
347
|
+
The runtime can pursue a goal, choose among alternatives, react to
|
|
348
|
+
changing state, recover from failed actions, and recognize when no
|
|
349
|
+
viable path remains using a world that has been explicitly structured in
|
|
350
|
+
advance.
|
|
351
|
+
|
|
352
|
+
An LLM can add judgment where judgment is useful.
|
|
353
|
+
|
|
354
|
+
It does not have to supply the structure that makes autonomy possible.
|
|
355
|
+
|
|
356
|
+
## Designing for autonomy
|
|
357
|
+
|
|
358
|
+
This suggests a different starting point for autonomous-system design.
|
|
359
|
+
|
|
360
|
+
Instead of asking only:
|
|
361
|
+
|
|
362
|
+
> How intelligent does the agent need to be?
|
|
363
|
+
|
|
364
|
+
we can also ask:
|
|
365
|
+
|
|
366
|
+
> What can the environment make explicit so the agent does not need to
|
|
367
|
+
> know it?
|
|
368
|
+
|
|
369
|
+
That question shifts attention from constructing increasingly capable
|
|
370
|
+
agents toward constructing environments in which useful autonomous
|
|
371
|
+
behavior can emerge from simpler mechanics.
|
|
372
|
+
|
|
373
|
+
GRAIL is one experiment in that direction.
|
|
374
|
+
|
|
375
|
+
Its working proposition is increasingly clear:
|
|
376
|
+
|
|
377
|
+
> **Define the environment, not the path.**
|
|
378
|
+
|
|
379
|
+
And beneath that proposition is an even more general one:
|
|
380
|
+
|
|
381
|
+
> **What is not in the agent must be in the environment.**
|