loopforge 3.8.1 → 3.8.3
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 +102 -128
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +121 -21
- package/dist/cli.js.map +1 -1
- package/dist/enforcement-gate.d.ts +7 -1
- package/dist/enforcement-gate.d.ts.map +1 -1
- package/dist/enforcement-gate.js +140 -34
- package/dist/enforcement-gate.js.map +1 -1
- package/dist/evidence-provider.d.ts +44 -2
- package/dist/evidence-provider.d.ts.map +1 -1
- package/dist/evidence-provider.js +125 -23
- package/dist/evidence-provider.js.map +1 -1
- package/dist/loop-store.d.ts.map +1 -1
- package/dist/loop-store.js +44 -7
- package/dist/loop-store.js.map +1 -1
- package/dist/mcp/round-lifecycle.d.ts +28 -1
- package/dist/mcp/round-lifecycle.d.ts.map +1 -1
- package/dist/mcp/round-lifecycle.js +89 -14
- package/dist/mcp/round-lifecycle.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +7 -0
- package/dist/mcp/server.js.map +1 -1
- package/dist/policy.d.ts +13 -3
- package/dist/policy.d.ts.map +1 -1
- package/dist/policy.js +49 -10
- package/dist/policy.js.map +1 -1
- package/dist/round-coordinator.d.ts +34 -0
- package/dist/round-coordinator.d.ts.map +1 -1
- package/dist/round-coordinator.js +87 -9
- package/dist/round-coordinator.js.map +1 -1
- package/dist/round-driver.d.ts +2 -0
- package/dist/round-driver.d.ts.map +1 -1
- package/dist/round-driver.js +1 -0
- package/dist/round-driver.js.map +1 -1
- package/dist/round-transaction.d.ts +2 -0
- package/dist/round-transaction.d.ts.map +1 -1
- package/dist/round-transaction.js +1 -0
- package/dist/round-transaction.js.map +1 -1
- package/dist/self-eval.d.ts +10 -0
- package/dist/self-eval.d.ts.map +1 -1
- package/dist/self-eval.js +14 -0
- package/dist/self-eval.js.map +1 -1
- package/dist/verification-gate.d.ts +16 -1
- package/dist/verification-gate.d.ts.map +1 -1
- package/dist/verification-gate.js +66 -25
- package/dist/verification-gate.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/loop_policy.json +59 -59
- package/package.json +1 -1
- package/skills/perception/SKILL.md +317 -414
|
@@ -1,414 +1,317 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: perception
|
|
3
|
-
description: Drive
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Perception
|
|
7
|
-
|
|
8
|
-
Use LoopForge when a
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
LoopForge has one factual source,
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
"
|
|
185
|
-
"
|
|
186
|
-
"
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
an `insufficient` posture is a statement about evidence, not about effort.
|
|
319
|
-
|
|
320
|
-
Errors arrive as `{ok: false, error: {code, message, retryable, ...}}`. `code` is
|
|
321
|
-
stable — branch on it, not on the prose in `message`. `evaluation_invalid`,
|
|
322
|
-
`contract_invalid`, `policy_invalid`, `round_id_required`, `round_id_mismatch`,
|
|
323
|
-
and `invalid_argument` are `retryable`: fix the payload and resubmit the same
|
|
324
|
-
`roundId`. `state_unavailable` means the record you asked for is not there (no
|
|
325
|
-
audit data for that loop, no such gate record), `session_not_found` that the
|
|
326
|
-
session is gone: state conditions, not payload defects — do not resubmit the
|
|
327
|
-
same payload hoping for a different answer. `gate_disabled` means the gate layer
|
|
328
|
-
is off in this policy, and `loop_already_running` that a session for this loop
|
|
329
|
-
already exists in this process — inspect or resume it instead of starting a
|
|
330
|
-
duplicate.
|
|
331
|
-
|
|
332
|
-
`completed` means the machine verified the completion: success plus every
|
|
333
|
-
contract item `verified`, or no active contract. An explicit `outcome:
|
|
334
|
-
"blocked"` (or `stop_reason: "blocked"` / `"needs_human_input"`) always stops as
|
|
335
|
-
`blocked`, never as `completed`. `incomplete` means you stopped while the
|
|
336
|
-
machine could not verify completion — claims the bound commands did not back;
|
|
337
|
-
contract verification debt that persisted past
|
|
338
|
-
`engine.unverified_claim_streak_limit` also ends here rather than accepting
|
|
339
|
-
another unverified round. `failed` means the Agent gave up. `max_rounds` is the
|
|
340
|
-
safety limit. `stalled` means the runtime could not produce the next round's
|
|
341
|
-
prompt. `enforcement_terminated` means repeated integrity failures reached a
|
|
342
|
-
terminal ladder. `paused` means the durable session remains available for
|
|
343
|
-
resume, and `cancelled` that the session was deleted.
|
|
344
|
-
|
|
345
|
-
## Prompt levels and views
|
|
346
|
-
|
|
347
|
-
L0 is a lean same-round retry, L1 is normal continuation, and L2 is full
|
|
348
|
-
rehydration. They control state density only and never prescribe a reasoning
|
|
349
|
-
technique. L2 is chosen from FACTS about the round — the first round, a plan or
|
|
350
|
-
checkpoint boundary, a committed recovery, a machine contradiction, a repeated
|
|
351
|
-
rejection, a changed objective, a previous state the runtime can no longer read
|
|
352
|
-
— never from a round counter, so nothing changes in the prompt just because the
|
|
353
|
-
loop has been running for a while. Protected prompt sections and
|
|
354
|
-
the token budget remain enforced; when the protected content alone exceeds the
|
|
355
|
-
ceiling the prompt records `protectedOverflow` rather than dropping it, and
|
|
356
|
-
which sections were rendered is recorded in the prompt artifact.
|
|
357
|
-
|
|
358
|
-
Use `loopforge_status` with `view: "session"` for the live round and typed
|
|
359
|
-
projection, `view: "loop"` for machine counts over committed rounds, `view: "all"`
|
|
360
|
-
after a restart, `view: "audit"` for the read-only completeness and evidence
|
|
361
|
-
audit, and `view: "explain"` (loopId, optional `round`) for the per-round "why"
|
|
362
|
-
view — the active contract, item statuses, observations, and flags. The same
|
|
363
|
-
view is available from the CLI as `loopforge explain LOOP_ID [--round N]
|
|
364
|
-
[--json]`. Use `loopforge_replay` for the committed timeline and round diffs.
|
|
365
|
-
Replay answers what happened; Audit checks whether facts and claims are
|
|
366
|
-
supported; Explain shows why a round was decided the way it was.
|
|
367
|
-
|
|
368
|
-
The optional `.loopforge/state/<loopId>-state.md` file is derived and can be
|
|
369
|
-
regenerated. In L2 the prompt may omit the full markdown state and point at
|
|
370
|
-
that file instead (pointer mode), so read it when the prompt says so — but it
|
|
371
|
-
is a derived view, never an independent source of truth.
|
|
372
|
-
|
|
373
|
-
## Control and delegation
|
|
374
|
-
|
|
375
|
-
Use `loopforge_pause` before an intentional interruption,
|
|
376
|
-
`loopforge_resume` to reconstruct a durable session, and `loopforge_stop` only
|
|
377
|
-
for an intentional terminal stop.
|
|
378
|
-
|
|
379
|
-
The two gate tools are opt-in (`policy.gate.enabled`, default false) and are
|
|
380
|
-
hidden from `tools/list` when disabled (a direct call then returns
|
|
381
|
-
`gate_disabled`). When enabled, preflight a high-risk action with
|
|
382
|
-
`loopforge_gate_check`, whose `action` is a structured descriptor:
|
|
383
|
-
|
|
384
|
-
- `description`: what the action does ("Deploy to production");
|
|
385
|
-
- `scope`: files, systems or services it touches;
|
|
386
|
-
- `effects`: any of `workspace_write`, `production`, `credentials`,
|
|
387
|
-
`data_migration`, `public_api`, `publish`, `payment`,
|
|
388
|
-
`external_communication`, `network`;
|
|
389
|
-
- `reversibility`: `reversible` / `recoverable` / `irreversible` / `unknown`;
|
|
390
|
-
- `authorization`: `agent_allowed` / `user_required` / `unknown`.
|
|
391
|
-
|
|
392
|
-
Classification is conservative: anything not provably safe is `user_required`,
|
|
393
|
-
which returns a gate id and an approval question. Present that question to the
|
|
394
|
-
human, record their decision with `loopforge_gate_resolve`, and cite the
|
|
395
|
-
approved gate id via `evaluation.gate_ids` in the round that performs the
|
|
396
|
-
action — an unapproved or unknown cited gate rejects the round. Safe
|
|
397
|
-
preparation work (investigation, dry-runs, rollback evidence) never needs a
|
|
398
|
-
gate. Remember: approval is recorded through you, the Agent — LoopForge cannot
|
|
399
|
-
machine-verify a human is present.
|
|
400
|
-
|
|
401
|
-
Delegation does not create a separate LoopForge mode. Give each worker a
|
|
402
|
-
self-contained subtask and relevant hard constraints, then place its result in
|
|
403
|
-
`worker_results` so discoveries can enter the next Canonical State.
|
|
404
|
-
|
|
405
|
-
## Rules
|
|
406
|
-
|
|
407
|
-
1. Execute the prompt instead of generating another prompt.
|
|
408
|
-
2. Submit one honest structured evaluation after each attempt.
|
|
409
|
-
3. Restore the workspace before working after backtrack.
|
|
410
|
-
4. Treat required command evidence and verification errors as authoritative.
|
|
411
|
-
5. Keep one loop focused on one user objective.
|
|
412
|
-
6. Do not advance a paused or stopped session through another process.
|
|
413
|
-
7. Continue within the same Agent task when possible. LoopForge preserves state
|
|
414
|
-
but does not create a background Agent.
|
|
1
|
+
---
|
|
2
|
+
name: perception
|
|
3
|
+
description: Drive multi-round coding tasks through LoopForge MCP so objectives, constraints, evidence, and decisions survive context loss and restarts. The external Agent remains responsible for planning, file changes, tools, and execution.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Perception
|
|
7
|
+
|
|
8
|
+
Use LoopForge when a task spans several meaningful work slices, must survive a
|
|
9
|
+
restart or context loss, or needs an auditable distinction between Agent claims
|
|
10
|
+
and machine-verified facts.
|
|
11
|
+
|
|
12
|
+
LoopForge has one factual source, committed typed round documents in the Vault,
|
|
13
|
+
and one cognitive source, Canonical State compiled from those documents. The
|
|
14
|
+
Agent still decides what to do and how to reason.
|
|
15
|
+
|
|
16
|
+
## Start
|
|
17
|
+
|
|
18
|
+
Call `loopforge_status` with `view: "all"` before starting. Reuse an existing
|
|
19
|
+
session for the same objective instead of opening a second loop.
|
|
20
|
+
|
|
21
|
+
Call `loopforge_start` with:
|
|
22
|
+
|
|
23
|
+
- `task`: the complete user objective;
|
|
24
|
+
- `constraints`: hard boundaries that must survive every round;
|
|
25
|
+
- optional `maxRounds`, `domain`, `loopId`, and `planSource`.
|
|
26
|
+
|
|
27
|
+
Keep the returned `sessionId`, `roundId`, prompt, and level. Pass the latest
|
|
28
|
+
`roundId` to every `loopforge_next`; it anchors the submission to the exact
|
|
29
|
+
round being reported.
|
|
30
|
+
|
|
31
|
+
## What is a round?
|
|
32
|
+
|
|
33
|
+
A round is one coherent work slice that can be described, checked, and
|
|
34
|
+
disposed of at the next boundary. It is not a fixed number of files, tokens,
|
|
35
|
+
commits, or minutes. A capable Agent may complete a large change in one round
|
|
36
|
+
when the change shares one objective, one evidence story, and one recovery
|
|
37
|
+
path. Split it when those boundaries diverge.
|
|
38
|
+
|
|
39
|
+
Before choosing the slice, ask:
|
|
40
|
+
|
|
41
|
+
1. **Coherence:** does the work serve one immediate objective rather than
|
|
42
|
+
several unrelated goals?
|
|
43
|
+
2. **Verifiability:** can the result and its hard constraints be checked with
|
|
44
|
+
the available tests, commands, or other machine observations?
|
|
45
|
+
3. **Disposition:** will the boundary produce a clear continuation, stop,
|
|
46
|
+
blocker, rejection, or recovery decision?
|
|
47
|
+
4. **Recovery:** can the slice be safely retried or rolled back without
|
|
48
|
+
invalidating unrelated work?
|
|
49
|
+
|
|
50
|
+
Make a round larger when changes are tightly coupled and can be verified
|
|
51
|
+
together. Make it smaller when uncertainty, external effects, evidence gaps,
|
|
52
|
+
or rollback risk is high. Do not combine independent objectives merely because
|
|
53
|
+
the Agent can edit them in one context. Do not split a single atomic change
|
|
54
|
+
only to create more round records.
|
|
55
|
+
|
|
56
|
+
At the end of a round, inspect the actual diff, relevant tests, hard
|
|
57
|
+
constraints, and remaining work. A completed slice is not the same as a
|
|
58
|
+
completed task.
|
|
59
|
+
|
|
60
|
+
## Plan the next slice
|
|
61
|
+
|
|
62
|
+
For work that spans rounds, submit `round_contract` as a proposal for the next
|
|
63
|
+
slice. Keep `work_item` narrow, bind each item to a configured evidence command
|
|
64
|
+
with `verify_with`, and limit `scope` to files or directories that slice may
|
|
65
|
+
touch. The proposal becomes active only after its declaring round commits.
|
|
66
|
+
While it is open, restating the same proposal continues it; a different
|
|
67
|
+
proposal is ignored as `contract_premature`. If the slice is blocked, report
|
|
68
|
+
`outcome: "blocked"` with a concrete `blocker` instead of silently replacing
|
|
69
|
+
the active contract.
|
|
70
|
+
|
|
71
|
+
This is a planning aid, not a second gate. LoopForge learns the plan only from
|
|
72
|
+
committed evaluation fields, contract proposals, observations, and changes.
|
|
73
|
+
|
|
74
|
+
## Execute a round
|
|
75
|
+
|
|
76
|
+
1. Execute the returned prompt and do the repository work.
|
|
77
|
+
2. Use the tools and reasoning approach that fit the slice.
|
|
78
|
+
3. Check actual evidence before claiming success.
|
|
79
|
+
4. Submit exactly one structured evaluation with `loopforge_next`.
|
|
80
|
+
|
|
81
|
+
After the strict boundary accepts the payload, LoopForge collects before/after
|
|
82
|
+
evidence, runs the **verification gate**, then runs the **enforcement gate**.
|
|
83
|
+
The verification gate checks evaluation consistency, evidence integrity, plan
|
|
84
|
+
and contract conformance, and progress and recovery. The enforcement gate
|
|
85
|
+
turns those findings into one disposition: accept, reject, backtrack, or
|
|
86
|
+
terminate.
|
|
87
|
+
|
|
88
|
+
The four core evaluation fields are strict:
|
|
89
|
+
|
|
90
|
+
| Field | Requirement |
|
|
91
|
+
| --- | --- |
|
|
92
|
+
| `success` | Boolean. `true` only when the whole objective and hard constraints are satisfied. |
|
|
93
|
+
| `output_summary` | String describing what changed and what was verified. |
|
|
94
|
+
| `constraint_violations` | Array of real violations, preferably using `c-XXXXXXXX` IDs. |
|
|
95
|
+
| `should_continue` | Boolean. `false` only when the whole task is complete. |
|
|
96
|
+
|
|
97
|
+
Useful optional fields include `execution_report` (`files_changed`,
|
|
98
|
+
`tests_reported`, `criterion_claims`, `contract_item_claims`, and
|
|
99
|
+
`progress_estimate`), `discovered_constraints`, `emerged_subtasks`,
|
|
100
|
+
`subgoal_updates`, `prompt_requests`, `round_contract`, `retroactiveClaims`,
|
|
101
|
+
`gate_ids`, `worker_results`, and objective or constraint revisions.
|
|
102
|
+
|
|
103
|
+
`emerged_subtasks` is the only sub-goal creation channel. It contains plain
|
|
104
|
+
descriptions, never `sg-` IDs. `subgoal_updates` changes existing active IDs;
|
|
105
|
+
done and canceled are terminal and cannot be reopened.
|
|
106
|
+
|
|
107
|
+
`outcome` may be `success`, `partial`, `failed`, or `blocked`. A blocked
|
|
108
|
+
outcome needs a concrete `blocker`; `stop_reason` of `blocked` or
|
|
109
|
+
`needs_human_input` also stops without claiming success.
|
|
110
|
+
|
|
111
|
+
Optional malformed values are normalized or dropped. The strict exceptions are
|
|
112
|
+
`subgoal_updates`, `round_contract`, and
|
|
113
|
+
`execution_report.contract_item_claims`. Shape, reference, duplicate, command,
|
|
114
|
+
and workspace-containment errors return `evaluation_invalid` or
|
|
115
|
+
`contract_invalid` before advance. Correct the payload and resubmit the same
|
|
116
|
+
`roundId`; nothing is committed and no rejection counter moves.
|
|
117
|
+
|
|
118
|
+
Every successful round still needs an `execution_report` with
|
|
119
|
+
`files_changed` and `tests_reported`. `no_change_reason` is an escape only when
|
|
120
|
+
no enabled verification command exists. It never creates evidence and never
|
|
121
|
+
excuses an open contract.
|
|
122
|
+
|
|
123
|
+
Agent reports are claims quoted for audit. They never become verified facts.
|
|
124
|
+
Do not infer a missing field from natural language or put a guessed evaluation
|
|
125
|
+
in free text.
|
|
126
|
+
|
|
127
|
+
## IDs and contracts
|
|
128
|
+
|
|
129
|
+
Prompts render stable IDs beside constraints, criteria, sub-goals, and contract
|
|
130
|
+
items. Prefer those IDs for `constraint_violations`, criterion claims, status
|
|
131
|
+
updates, and item claims.
|
|
132
|
+
|
|
133
|
+
A sub-goal ID belongs to its declaration event. Re-declaring the same text in a
|
|
134
|
+
later round creates a new sub-goal. Status changes require the exact active
|
|
135
|
+
`sg-` ID; description matching is not a fallback.
|
|
136
|
+
|
|
137
|
+
A Round Contract is a set of evidence-bound items, not prose. Each item must
|
|
138
|
+
bind at least one configured, enabled, after-capable command. The runtime
|
|
139
|
+
derives content-addressed `rc-XXXXXXXX` and `rci-XXXXXXXX` IDs, so restating an
|
|
140
|
+
unchanged proposal keeps its identity. `subgoal_refs` belongs on the item; a
|
|
141
|
+
machine-verified item backs exactly the sub-goals it names, without changing
|
|
142
|
+
their declared `SubGoal.status`.
|
|
143
|
+
|
|
144
|
+
Item status is machine-derived:
|
|
145
|
+
|
|
146
|
+
- `pending`: not claimed as met;
|
|
147
|
+
- `insufficient`: claimed as met but not backed by all required observations;
|
|
148
|
+
- `contradicted`: a bound observation fails, or its entrypoint/configuration is
|
|
149
|
+
no longer trustworthy;
|
|
150
|
+
- `verified`: the Agent claims `met`, every bound command passes in the closing
|
|
151
|
+
round's after phase, and the declaration binding remains intact.
|
|
152
|
+
|
|
153
|
+
The contract closes only when every item is `verified` or a round reports
|
|
154
|
+
`outcome: "blocked"`. Repeated unbacked claims create bounded verification
|
|
155
|
+
debt. The same-check streak escalates at
|
|
156
|
+
`engine.unverified_claim_streak_limit` (default 3) instead of retrying forever.
|
|
157
|
+
|
|
158
|
+
Sub-goals may evolve during execution. LoopForge does not use fuzzy intent or
|
|
159
|
+
similarity to judge drift. The enforced boundary is contract `scope`: work
|
|
160
|
+
outside it is `round_scope_drift`, a machine fact no explanation waives. Revert
|
|
161
|
+
the out-of-scope change, or close the contract as blocked and declare the
|
|
162
|
+
expanded scope in a new proposal whose `scope` covers **every** file this round
|
|
163
|
+
changed outside the current one — a partial expansion is still drift.
|
|
164
|
+
|
|
165
|
+
## Evidence commands
|
|
166
|
+
|
|
167
|
+
Contract items are backed by commands the OPERATOR configures. The Agent never
|
|
168
|
+
declares one, and does not discover or run project scripts to invent one. They
|
|
169
|
+
live in `loop_policy.json` under `evidence.commands`, in the workspace the
|
|
170
|
+
server was started in:
|
|
171
|
+
|
|
172
|
+
```json
|
|
173
|
+
{
|
|
174
|
+
"version": "4",
|
|
175
|
+
"evidence": {
|
|
176
|
+
"commands": [{
|
|
177
|
+
"name": "verify",
|
|
178
|
+
"enabled": true,
|
|
179
|
+
"executable": "node",
|
|
180
|
+
"args": ["scripts/verify.mjs"],
|
|
181
|
+
"cwd": ".",
|
|
182
|
+
"phase": "after",
|
|
183
|
+
"required": true,
|
|
184
|
+
"timeout_ms": 120000,
|
|
185
|
+
"max_output_chars": 8000,
|
|
186
|
+
"success_exit_codes": [0]
|
|
187
|
+
}]
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
`executable` and `args` are spawned without a shell and confined to the
|
|
193
|
+
workspace. `loopforge doctor` statically checks every configured command —
|
|
194
|
+
its name, executable, arguments, timeouts, and workspace containment — and
|
|
195
|
+
never executes one.
|
|
196
|
+
|
|
197
|
+
Every prepared round returns `capability`: which providers are available, which
|
|
198
|
+
commands are enabled and after-capable, and `contractVerificationAvailable`.
|
|
199
|
+
When that is `false`, no configured command can back a contract item: run
|
|
200
|
+
rounds without a contract instead of declaring items that cannot close. The
|
|
201
|
+
`warnings` list states the same thing in words.
|
|
202
|
+
|
|
203
|
+
A command's ENTRYPOINT is the file it names plus `package.json` when a package
|
|
204
|
+
manager runs it. It must already be part of the workspace when the round
|
|
205
|
+
starts, and it must not change during the round that runs it — the runtime
|
|
206
|
+
records those files at round start and compares them afterwards, whether or not
|
|
207
|
+
git can see them. A changed entrypoint makes the observation untrustworthy:
|
|
208
|
+
restore it to its round-start content. Do not author the verification script
|
|
209
|
+
inside the round you expect it to verify — that round cannot be closed by it.
|
|
210
|
+
|
|
211
|
+
To keep a script that must survive a rollback, it has to be part of the
|
|
212
|
+
committed workspace rather than an uncommitted change: the post-backtrack
|
|
213
|
+
restore check rejects a skipped file that is still byte-identical to its state
|
|
214
|
+
at the rollback, so a script left sitting in the working tree blocks the redo.
|
|
215
|
+
Prepare it before the round that depends on it.
|
|
216
|
+
|
|
217
|
+
## Backtrack and recovery
|
|
218
|
+
|
|
219
|
+
A progress stall is machine-first when Git history is observable over the
|
|
220
|
+
lookback window. Self-reported `progress_estimate` is only a fallback when
|
|
221
|
+
machine history cannot be read. Machine motion can excuse a stall but cannot
|
|
222
|
+
create one. A machine-backed success round is finishing, even if its closing
|
|
223
|
+
round changes no files.
|
|
224
|
+
|
|
225
|
+
Backtrack records a rollback directive and restores the round counter to the
|
|
226
|
+
last clean committed round. Rejected attempts are never history. The next
|
|
227
|
+
submission is the redo of `restorePoint + 1` and must reuse the prompt's round
|
|
228
|
+
ID. A successful redo retires the rollback record.
|
|
229
|
+
|
|
230
|
+
The Recovery Brief identifies the trigger, restore point, redo ID, failed
|
|
231
|
+
approaches, falsified assumptions, valid discoveries, files to revert, and
|
|
232
|
+
target HEAD. It states restoration facts, not a prescribed command.
|
|
233
|
+
|
|
234
|
+
When backtrack occurs:
|
|
235
|
+
|
|
236
|
+
1. Restore the workspace exactly as requested before doing more work.
|
|
237
|
+
2. Read the Recovery Brief, restored prompt, and derived state.
|
|
238
|
+
3. Do not repeat a failed approach without addressing its cause.
|
|
239
|
+
4. Carry valid discoveries into later evaluations.
|
|
240
|
+
|
|
241
|
+
If the rolled-back work used an active contract, close the stalled contract in
|
|
242
|
+
the redo with `outcome: "blocked"` and declare the revised contract in that
|
|
243
|
+
same submission. Restating the stalled contract commits more of the same.
|
|
244
|
+
|
|
245
|
+
## Interpret results
|
|
246
|
+
|
|
247
|
+
- Non-null `prompt`: execute it and submit the next evaluation.
|
|
248
|
+
- `enforcementAction: "reject"`: retry the same logical round and ID; the
|
|
249
|
+
attempt increases.
|
|
250
|
+
- `enforcementAction: "backtrack"`: restore the workspace, then continue from
|
|
251
|
+
the restored prompt and round.
|
|
252
|
+
- Null `prompt`: inspect `stopReason`.
|
|
253
|
+
|
|
254
|
+
Read `verificationStatus`, `roundSuccess`, `level`, `warnings`, and
|
|
255
|
+
`enforcementReason` before planning the next slice. `trusted` means claimed
|
|
256
|
+
work is machine-backed, `insufficient` means evidence is missing, and
|
|
257
|
+
`contradicted` means a machine fact denies a claim. These are evidence
|
|
258
|
+
postures, not subjective quality scores.
|
|
259
|
+
|
|
260
|
+
Errors use `{ok: false, error: {code, message, retryable, ...}}`. Branch on the
|
|
261
|
+
stable `code`, not the prose in `message`. Payload errors such as
|
|
262
|
+
`evaluation_invalid`, `contract_invalid`, `policy_invalid`, and round-ID
|
|
263
|
+
errors are retryable with the same ID. `session_not_found`, `state_unavailable`,
|
|
264
|
+
and `gate_disabled` describe state or policy; do not blindly resubmit.
|
|
265
|
+
|
|
266
|
+
`completed` means success plus every active contract item is `verified`, or
|
|
267
|
+
there is no active contract. Explicit `blocked` always wins over success.
|
|
268
|
+
`incomplete` means completion was not machine-verified. Other terminal reasons
|
|
269
|
+
include `failed`, `max_rounds`, `stalled`, `enforcement_terminated`, `paused`,
|
|
270
|
+
and `cancelled`.
|
|
271
|
+
|
|
272
|
+
## Prompt levels and views
|
|
273
|
+
|
|
274
|
+
L0 is a lean same-round retry, L1 normal continuation, and L2 full
|
|
275
|
+
rehydration. They control state density only, never a reasoning technique. L2
|
|
276
|
+
comes from round facts such as the first round, a plan or checkpoint boundary,
|
|
277
|
+
recovery, contradiction, or repeated rejection. It is not a round-count timer.
|
|
278
|
+
|
|
279
|
+
Use `loopforge_status` with `view: "session"` for the live round,
|
|
280
|
+
`view: "loop"` for committed health, `view: "all"` after a restart,
|
|
281
|
+
`view: "audit"` for completeness and evidence, and `view: "explain"` for a
|
|
282
|
+
round's active contract, observations, flags, and decision. Use
|
|
283
|
+
`loopforge_replay` for the committed timeline and diffs.
|
|
284
|
+
|
|
285
|
+
The optional `.loopforge/state/<loopId>-state.md` is derived and regenerable.
|
|
286
|
+
Read it when an L2 prompt points to it, but never treat it as a second source
|
|
287
|
+
of truth.
|
|
288
|
+
|
|
289
|
+
## Gates and delegation
|
|
290
|
+
|
|
291
|
+
Use `loopforge_pause` for an intentional interruption,
|
|
292
|
+
`loopforge_resume` to reconstruct a durable session, and `loopforge_stop` only
|
|
293
|
+
for an intentional terminal stop.
|
|
294
|
+
|
|
295
|
+
The two gate tools are opt-in through `policy.gate.enabled`. When enabled,
|
|
296
|
+
`loopforge_gate_check` preflights a structured action with its description,
|
|
297
|
+
scope, effects, reversibility, and authorization. Classification is
|
|
298
|
+
conservative: anything not provably safe becomes `user_required`. Present the
|
|
299
|
+
approval question, record the decision with `loopforge_gate_resolve`, and cite
|
|
300
|
+
the approved gate ID in `evaluation.gate_ids`. LoopForge records the process,
|
|
301
|
+
but cannot prove that a human was present because the Agent submits the resolve
|
|
302
|
+
call. Safe investigation and dry-runs need no gate.
|
|
303
|
+
|
|
304
|
+
Delegation does not create another LoopForge mode. Give each worker a
|
|
305
|
+
self-contained subtask and hard constraints, then place the result in
|
|
306
|
+
`worker_results` so it can enter the next Canonical State.
|
|
307
|
+
|
|
308
|
+
## Rules
|
|
309
|
+
|
|
310
|
+
1. Execute the prompt instead of generating another prompt.
|
|
311
|
+
2. Submit one honest structured evaluation after each attempt.
|
|
312
|
+
3. Treat required command evidence and verification findings as authoritative.
|
|
313
|
+
4. Restore the workspace before working after backtrack.
|
|
314
|
+
5. Keep one loop focused on one user objective.
|
|
315
|
+
6. Do not advance a paused or stopped session through another process.
|
|
316
|
+
7. Continue in the same Agent task when possible. LoopForge preserves state but
|
|
317
|
+
does not create a background Agent.
|