loopforge 2.11.0 → 3.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 +145 -128
- package/dist/canonical-event-writer.d.ts +20 -0
- package/dist/canonical-event-writer.d.ts.map +1 -0
- package/dist/canonical-event-writer.js +131 -0
- package/dist/canonical-event-writer.js.map +1 -0
- package/dist/canonical-state.d.ts +20 -16
- package/dist/canonical-state.d.ts.map +1 -1
- package/dist/canonical-state.js +170 -61
- package/dist/canonical-state.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +11 -10
- package/dist/cli.js.map +1 -1
- package/dist/cognitive-governance.d.ts +48 -0
- package/dist/cognitive-governance.d.ts.map +1 -0
- package/dist/cognitive-governance.js +226 -0
- package/dist/cognitive-governance.js.map +1 -0
- package/dist/compiler-subgoals.d.ts +7 -0
- package/dist/compiler-subgoals.d.ts.map +1 -0
- package/dist/compiler-subgoals.js +93 -0
- package/dist/compiler-subgoals.js.map +1 -0
- package/dist/derive-id.d.ts +12 -0
- package/dist/derive-id.d.ts.map +1 -0
- package/dist/derive-id.js +31 -0
- package/dist/derive-id.js.map +1 -0
- package/dist/evidence-provider.d.ts +23 -21
- package/dist/evidence-provider.d.ts.map +1 -1
- package/dist/evidence-provider.js +34 -74
- package/dist/evidence-provider.js.map +1 -1
- package/dist/generate-schema.js +90 -2
- package/dist/generate-schema.js.map +1 -1
- package/dist/index.d.ts +22 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -16
- package/dist/index.js.map +1 -1
- package/dist/loop-compiler.d.ts +1 -1
- package/dist/loop-compiler.d.ts.map +1 -1
- package/dist/loop-compiler.js +250 -337
- package/dist/loop-compiler.js.map +1 -1
- package/dist/loop-extras-parser.d.ts +2 -2
- package/dist/loop-extras-parser.d.ts.map +1 -1
- package/dist/loop-extras-parser.js +2 -2
- package/dist/loop-extras-parser.js.map +1 -1
- package/dist/loop-store.d.ts +20 -58
- package/dist/loop-store.d.ts.map +1 -1
- package/dist/loop-store.js +232 -309
- package/dist/loop-store.js.map +1 -1
- package/dist/mcp/server.d.ts +3 -3
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +83 -13
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/session-projection.d.ts +5 -0
- package/dist/mcp/session-projection.d.ts.map +1 -0
- package/dist/mcp/session-projection.js +18 -0
- package/dist/mcp/session-projection.js.map +1 -0
- package/dist/mcp/session-queue.d.ts +3 -0
- package/dist/mcp/session-queue.d.ts.map +1 -0
- package/dist/mcp/session-queue.js +18 -0
- package/dist/mcp/session-queue.js.map +1 -0
- package/dist/mcp/session-types.d.ts +72 -0
- package/dist/mcp/session-types.d.ts.map +1 -0
- package/dist/mcp/session-types.js +2 -0
- package/dist/mcp/session-types.js.map +1 -0
- package/dist/mcp/session.d.ts +49 -93
- package/dist/mcp/session.d.ts.map +1 -1
- package/dist/mcp/session.js +544 -245
- package/dist/mcp/session.js.map +1 -1
- package/dist/mcp/tools.d.ts +26 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +399 -274
- package/dist/mcp/tools.js.map +1 -1
- package/dist/policy-metrics.d.ts +17 -1
- package/dist/policy-metrics.d.ts.map +1 -1
- package/dist/policy-metrics.js +164 -1
- package/dist/policy-metrics.js.map +1 -1
- package/dist/policy.d.ts +34 -18
- package/dist/policy.d.ts.map +1 -1
- package/dist/policy.js +113 -18
- package/dist/policy.js.map +1 -1
- package/dist/prompt-assembler.d.ts +5 -3
- package/dist/prompt-assembler.d.ts.map +1 -1
- package/dist/prompt-assembler.js +126 -77
- package/dist/prompt-assembler.js.map +1 -1
- package/dist/prompt-policy.d.ts +8 -1
- package/dist/prompt-policy.d.ts.map +1 -1
- package/dist/prompt-policy.js +26 -8
- package/dist/prompt-policy.js.map +1 -1
- package/dist/protocol.d.ts +232 -192
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +15 -100
- package/dist/protocol.js.map +1 -1
- package/dist/replay.d.ts +11 -3
- package/dist/replay.d.ts.map +1 -1
- package/dist/replay.js +51 -14
- package/dist/replay.js.map +1 -1
- package/dist/round-commit-store.d.ts +12 -0
- package/dist/round-commit-store.d.ts.map +1 -0
- package/dist/round-commit-store.js +13 -0
- package/dist/round-commit-store.js.map +1 -0
- package/dist/round-coordinator.d.ts +25 -18
- package/dist/round-coordinator.d.ts.map +1 -1
- package/dist/round-coordinator.js +83 -71
- package/dist/round-coordinator.js.map +1 -1
- package/dist/round-driver.d.ts +14 -10
- package/dist/round-driver.d.ts.map +1 -1
- package/dist/round-driver.js +9 -13
- package/dist/round-driver.js.map +1 -1
- package/dist/round-gate.d.ts +31 -0
- package/dist/round-gate.d.ts.map +1 -0
- package/dist/round-gate.js +259 -0
- package/dist/round-gate.js.map +1 -0
- package/dist/round-recovery.d.ts +17 -0
- package/dist/round-recovery.d.ts.map +1 -0
- package/dist/round-recovery.js +117 -0
- package/dist/round-recovery.js.map +1 -0
- package/dist/round-report.d.ts +16 -0
- package/dist/round-report.d.ts.map +1 -0
- package/dist/round-report.js +401 -0
- package/dist/round-report.js.map +1 -0
- package/dist/round-transaction.d.ts +19 -12
- package/dist/round-transaction.d.ts.map +1 -1
- package/dist/round-transaction.js +102 -88
- package/dist/round-transaction.js.map +1 -1
- package/dist/runtime-services.d.ts +59 -0
- package/dist/runtime-services.d.ts.map +1 -0
- package/dist/runtime-services.js +460 -0
- package/dist/runtime-services.js.map +1 -0
- package/dist/storage.d.ts +3 -9
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +6 -17
- package/dist/storage.js.map +1 -1
- package/dist/token-utils.d.ts +9 -8
- package/dist/token-utils.d.ts.map +1 -1
- package/dist/token-utils.js +50 -10
- package/dist/token-utils.js.map +1 -1
- package/dist/vault-format.d.ts +4 -0
- package/dist/vault-format.d.ts.map +1 -0
- package/dist/vault-format.js +4 -0
- package/dist/vault-format.js.map +1 -0
- package/dist/vault-types.d.ts +24 -0
- package/dist/vault-types.d.ts.map +1 -0
- package/dist/vault-types.js +2 -0
- package/dist/vault-types.js.map +1 -0
- package/loop_policy.json +10 -12
- package/loopforge-policy.json +340 -0
- package/package.json +12 -6
- package/skills/perception/SKILL.md +199 -164
- package/dist/backends/interface.d.ts +0 -39
- package/dist/backends/interface.d.ts.map +0 -1
- package/dist/backends/interface.js +0 -6
- package/dist/backends/interface.js.map +0 -1
- package/dist/enforcement-gate.d.ts +0 -71
- package/dist/enforcement-gate.d.ts.map +0 -1
- package/dist/enforcement-gate.js +0 -744
- package/dist/enforcement-gate.js.map +0 -1
- package/dist/engine.d.ts +0 -59
- package/dist/engine.d.ts.map +0 -1
- package/dist/engine.js +0 -596
- package/dist/engine.js.map +0 -1
- package/dist/self-eval.d.ts +0 -23
- package/dist/self-eval.d.ts.map +0 -1
- package/dist/self-eval.js +0 -181
- package/dist/self-eval.js.map +0 -1
- package/dist/verification-gate.d.ts +0 -56
- package/dist/verification-gate.d.ts.map +0 -1
- package/dist/verification-gate.js +0 -563
- package/dist/verification-gate.js.map +0 -1
|
@@ -1,193 +1,228 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: perception
|
|
3
|
-
description: Drive a recoverable multi-round
|
|
3
|
+
description: Drive a recoverable multi-round task through the LoopForge MCP runtime while the Agent remains the execution owner.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Perception
|
|
7
7
|
|
|
8
|
-
Use LoopForge
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
Use LoopForge for work that spans multiple context windows, needs an auditable
|
|
9
|
+
record, or must survive a process restart. LoopForge stores canonical facts and
|
|
10
|
+
compiles prompts; you remain responsible for inspecting the repository,
|
|
11
|
+
editing files, running tools, and making technical decisions.
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
There is one public execution path. Do not create a second plan scheduler,
|
|
14
|
+
background Agent, MCP Task, or local shadow state machine.
|
|
14
15
|
|
|
15
|
-
## Start
|
|
16
|
+
## 1. Start one loop
|
|
16
17
|
|
|
17
18
|
Call `loopforge_start` with:
|
|
18
19
|
|
|
19
|
-
- `task`: the complete user objective
|
|
20
|
-
- `constraints`: hard boundaries that must survive every round
|
|
21
|
-
- `
|
|
22
|
-
|
|
20
|
+
- `task`: the complete user objective, not a short reminder;
|
|
21
|
+
- `constraints`: hard boundaries that must survive every round;
|
|
22
|
+
- `successCriteria`: explicit verifiable completion criteria when the task has
|
|
23
|
+
more than the default objective-level criterion;
|
|
24
|
+
- `maxRounds`: an explicit safety limit when the default (100) is unsuitable;
|
|
25
|
+
- `domain`: an optional technology or repository hint;
|
|
26
|
+
- `planSource`: an optional path to a user-provided plan (reference only).
|
|
23
27
|
|
|
24
|
-
Keep the returned `sessionId`, `roundId`, prompt, and
|
|
28
|
+
Keep the returned `sessionId`, `loopId`, `roundId`, prompt, and hashes. Execute
|
|
29
|
+
the returned prompt in the bound workspace before submitting a report.
|
|
25
30
|
|
|
26
|
-
##
|
|
31
|
+
## 2. Submit `RoundReport`
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
4. Call `loopforge_next` with `sessionId` and a structured `evaluation`.
|
|
32
|
-
|
|
33
|
-
### Evaluation fields
|
|
34
|
-
|
|
35
|
-
| Field | Rule |
|
|
36
|
-
| --- | --- |
|
|
37
|
-
| `success` | `true` only when the whole objective and every hard constraint are satisfied. |
|
|
38
|
-
| `output_summary` | State what changed and what was verified this round. |
|
|
39
|
-
| `constraint_violations` | Report real violations. Use constraint IDs (`c-XXXXXXXX`) for exact matching. Do not hide violations to force progress. |
|
|
40
|
-
| `should_continue` | `false` only when the entire task is complete. |
|
|
41
|
-
| `execution_evidence` | `files_changed`, `test_results`, `success_criteria_met`, `success_criteria_remaining`, `progress_estimate`. Use criterion IDs (`cr-XXXXXXXX`) in `success_criteria_met`/`_remaining`. |
|
|
42
|
-
| `discovered_constraints` | New guardrails found this round. Will be assigned stable IDs by the compiler. |
|
|
43
|
-
| `objective_refinement` | Refine the objective when repository evidence changes its meaning. |
|
|
44
|
-
| `emerged_subtasks` | New sub-problems that surfaced. Use clear, distinct descriptions. |
|
|
45
|
-
| `completed_subtasks` | Sub-goal IDs (`sg-XXXXXXXX`) or descriptions you finished this round. |
|
|
46
|
-
| `blocked_subtasks` | Sub-goal IDs or descriptions that cannot proceed. |
|
|
47
|
-
| `canceled_subtasks` | Sub-goal IDs or descriptions that are no longer needed. |
|
|
48
|
-
| `retracted_constraints` | Constraints the agent now believes are wrong or irrelevant. |
|
|
49
|
-
| `revised_success_criteria` | Old → new revisions for criteria discovered to be incorrect. |
|
|
50
|
-
| `wrong_assumptions` | Assumptions disproved this round. |
|
|
51
|
-
| `next_action` | What you plan to do in the next round. Be specific — the verification gate compares this against your actual output. |
|
|
52
|
-
| `compression_checkpoint` | Set `true` and include `checkpoint_label` when you complete a major phase. |
|
|
53
|
-
| `drift_clarification` | Required when you pivot from your declared `next_action`. Must include specific constraint/criterion/sub-goal IDs or file paths. Filler text without concrete references will be rejected. |
|
|
54
|
-
| `prompt_requests` | `emphasize` (what to highlight next round), `expand` (sections to expand), `confusion_points` (what you're confused about). |
|
|
55
|
-
| `stop_reason` | When `should_continue=false` and `success=false`: `"gave_up"`, `"blocked"`, or `"needs_human_input"`. |
|
|
56
|
-
| `worker_results` | Record delegated subtask results and discoveries from sub-agents. |
|
|
57
|
-
|
|
58
|
-
Minimal evaluation:
|
|
33
|
+
Call `loopforge_next` after an accepted round. Call `loopforge_retry` only when
|
|
34
|
+
the previous logical round was rejected. Both calls require `sessionId` and a
|
|
35
|
+
canonical report; free-form text and the old `status` report are invalid.
|
|
59
36
|
|
|
60
37
|
```json
|
|
61
38
|
{
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
}
|
|
39
|
+
"format": "loopforge.round-report",
|
|
40
|
+
"outcome": "partial",
|
|
41
|
+
"continuation": "continue",
|
|
42
|
+
"summary": "Implemented the parser and ran focused tests.",
|
|
43
|
+
"violations": [],
|
|
44
|
+
"evidence": {
|
|
45
|
+
"files": ["src/parser.ts", "test/parser.test.ts"],
|
|
46
|
+
"checks": [{"name": "npm test -- parser", "status": "passed", "counts": {"passed": 8, "failed": 0, "skipped": 0}}],
|
|
47
|
+
"claims": [{"id": "claim-0123456789ab", "targetId": "cr-abcdef12", "evidenceRefs": ["command:npm test -- parser"]}],
|
|
48
|
+
"provenance": {}
|
|
49
|
+
},
|
|
50
|
+
"agentIntent": "Add parser regression coverage next"
|
|
73
51
|
}
|
|
74
52
|
```
|
|
75
53
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
The prompt renders stable IDs beside every constraint, criterion, and sub-goal:
|
|
79
|
-
|
|
80
|
-
- **Constraints:** `[c-a3f2b1c0] No plaintext passwords`
|
|
81
|
-
- **Criteria:** `[cr-b5a6c7d8] Unit test coverage ≥ 90%`
|
|
82
|
-
- **Sub-goals:** `[sg-f1e2d3c4] Add error handling to login`
|
|
83
|
-
|
|
84
|
-
**Prefer IDs over descriptions** in `constraint_violations`, `success_criteria_met`/`_remaining`, `completed_subtasks`, `blocked_subtasks`, `canceled_subtasks`, and `drift_clarification`. Exact ID matching eliminates ambiguity — Jaccard similarity is a fallback, not the primary path.
|
|
85
|
-
|
|
86
|
-
## Backtrack — when the loop rewinds
|
|
87
|
-
|
|
88
|
-
When progress stalls for multiple rounds, LoopForge triggers a **backtrack**:
|
|
89
|
-
the round counter rolls back to the last clean round, failed work is discarded,
|
|
90
|
-
and a diagnosis is injected into the prompt.
|
|
91
|
-
|
|
92
|
-
**When you receive a backtrack prompt:**
|
|
93
|
-
|
|
94
|
-
1. **Restore your workspace first.** The prompt includes a "Workspace Restore
|
|
95
|
-
Required" section with exact `git checkout -- . && git clean -fd` commands.
|
|
96
|
-
Your working directory still contains changes from the failed rounds —
|
|
97
|
-
you MUST discard them before working.
|
|
98
|
-
2. **Read the restored state.** The prompt reflects the clean round's vault
|
|
99
|
-
state. The state file shows the correct full picture.
|
|
100
|
-
3. **Do NOT repeat the failed approach.** The diagnosis explains why the
|
|
101
|
-
previous path failed. Choose a different technique or decomposition.
|
|
102
|
-
4. **Preserved discoveries** from skipped rounds are merged into the active
|
|
103
|
-
constraints — they remain valid even though the rounds were discarded.
|
|
104
|
-
|
|
105
|
-
If you skip the workspace restore and work on dirty files, the verification
|
|
106
|
-
gate will **reject** your next submission with a `backtrack_workspace_not_restored`
|
|
107
|
-
flag.
|
|
54
|
+
### Outcome versus continuation
|
|
108
55
|
|
|
109
|
-
|
|
56
|
+
- `outcome` is only this round's result: `success`, `partial`, `failed`, or
|
|
57
|
+
`blocked`.
|
|
58
|
+
- `continuation` is only the request to start another round: `continue` or
|
|
59
|
+
`stop`.
|
|
60
|
+
- `success` does not prove the total objective is complete. Completion requires
|
|
61
|
+
runtime-verified claims for every remaining criterion, no contradictory
|
|
62
|
+
checks, and no unresolved User Gate.
|
|
63
|
+
- `blocked` requires a `blocker` object. Use `continuation: "stop"` for a
|
|
64
|
+
user decision, external dependency, or side effect that must not be guessed.
|
|
65
|
+
An Agent-resolvable blocker may use `continue`, but state the required
|
|
66
|
+
evidence and resolution.
|
|
110
67
|
|
|
111
|
-
|
|
112
|
-
against your actual `output_summary` this round. A mismatch triggers an
|
|
113
|
-
`intent_drift` flag.
|
|
68
|
+
### Report fields
|
|
114
69
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
70
|
+
| Field | How to use it |
|
|
71
|
+
| --- | --- |
|
|
72
|
+
| `summary` | Describe concrete work and observations from this round. |
|
|
73
|
+
| `violations` | List every actual hard-constraint violation; do not hide one to obtain acceptance. Prefer `c-XXXXXXXX` IDs. |
|
|
74
|
+
| `evidence` | Report files, checks, claims and references. Agent provenance is only a claim until a runtime provider observes it. |
|
|
75
|
+
| `discoveries` | Record wrong assumptions, emerged work, durable facts and newly discovered constraints. |
|
|
76
|
+
| `subGoalEvents` | Report completed, blocked or canceled existing sub-goals. Do not invent a second sub-goal lifecycle. Prefer `sg-XXXXXXXX` IDs. |
|
|
77
|
+
| `constraintEvents` | Retire a constraint only when repository evidence shows it is no longer valid. |
|
|
78
|
+
| `criterionRevisions` | Propose an old-to-new criterion change; never silently replace the user's objective. |
|
|
79
|
+
| `objectiveRefinement` | Add a safe clarification when evidence changes the interpretation; it is validated by the runtime. |
|
|
80
|
+
| `phaseBoundaryProposal` | Suggest a phase label and reason. The runtime decides whether the boundary is real. |
|
|
81
|
+
| `contextRequest` | Per-round emphasis, expansion or confusion requests. It is consumed once and is not durable state. |
|
|
82
|
+
| `agentIntent` | Optional Agent suggestion used only for audit and drift comparison. Runtime-derived Focus, Todo and Suggested Next Action take precedence. |
|
|
83
|
+
| `driftClarification` | When drift is detected, provide a concrete explanation and a criterion/constraint ID or observed file path. Runtime validates it; do not submit a waiver boolean. |
|
|
84
|
+
|
|
85
|
+
Do not submit derived `currentFocus`, `todoProjection`, `handoff`,
|
|
86
|
+
`progress`, `failedPatterns`, `nextAction`, or `verifiedFacts` as alternate
|
|
87
|
+
facts. These are internal or derived views. A progress estimate, if present in
|
|
88
|
+
the evidence supplied to an embedding, is never authoritative.
|
|
89
|
+
|
|
90
|
+
## 3. Evidence discipline
|
|
91
|
+
|
|
92
|
+
Use stable IDs shown in the prompt:
|
|
93
|
+
|
|
94
|
+
- constraints: `[c-a3f2b1c0]`;
|
|
95
|
+
- criteria: `[cr-b5a6c7d8]`;
|
|
96
|
+
- sub-goals: `[sg-f1e2d3c4]`.
|
|
97
|
+
|
|
98
|
+
Claims should reference a concrete file, check, or provider observation. Do not
|
|
99
|
+
mark your own provenance `verified` to force progress. Runtime providers may
|
|
100
|
+
replace claimed evidence with `verified`, `contradicted`, or `unavailable`.
|
|
101
|
+
Missing provider output is unavailable, not a pass. A rejected attempt and its
|
|
102
|
+
claims are not canonical facts.
|
|
103
|
+
|
|
104
|
+
## 4. Retry, backtrack and continuation
|
|
105
|
+
|
|
106
|
+
Read the returned `decision` and `enforcementAction`:
|
|
107
|
+
|
|
108
|
+
- `accepted`: execute the returned prompt for the next round;
|
|
109
|
+
- `rejected`: correct the evidence or work and call `loopforge_retry`; keep the
|
|
110
|
+
same logical `roundId` and do not call `next` to bypass rejection;
|
|
111
|
+
- `backtracked`: use the returned restore round and requirements, then continue
|
|
112
|
+
from the new prompt;
|
|
113
|
+
- `stopped` or `terminated`: do not submit another report unless a new loop is
|
|
114
|
+
explicitly started.
|
|
115
|
+
|
|
116
|
+
Backtrack is advisory and bounded. It never changes workspace files. Follow the
|
|
117
|
+
exact paths and checks returned by LoopForge, inspect the resulting workspace,
|
|
118
|
+
and report the restoration evidence. Never improvise an unbounded destructive
|
|
119
|
+
command such as `git clean -fd` or `git reset --hard`; ask for a User Gate when
|
|
120
|
+
the required action is destructive or authorization is unclear.
|
|
121
|
+
|
|
122
|
+
## 5. User Gate and Agent Gate
|
|
123
|
+
|
|
124
|
+
For a risky action, call `loopforge_gate_check` with:
|
|
127
125
|
|
|
128
|
-
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"description": "Apply the production database migration",
|
|
129
|
+
"scope": ["db/migrations/2026-01.sql"],
|
|
130
|
+
"effects": ["data_migration", "production"],
|
|
131
|
+
"reversibility": "recoverable",
|
|
132
|
+
"authorization": "user_required"
|
|
133
|
+
}
|
|
134
|
+
```
|
|
129
135
|
|
|
130
|
-
|
|
136
|
+
User Gate is required for production, credentials, data migration, publishing,
|
|
137
|
+
payment, external communication, public API changes, irreversible or unknown
|
|
138
|
+
actions, and unknown authorization. Limit the blocked scope and continue only
|
|
139
|
+
with allowed read-only investigation or dry runs. Agent Gate is for bounded,
|
|
140
|
+
reversible, explicitly `agent_allowed` workspace work or ordinary technical
|
|
141
|
+
blockers. Resolve a User Gate with `loopforge_gate_resolve` using the exact same
|
|
142
|
+
descriptor; its `actionHash` invalidates an approval if the action changes.
|
|
131
143
|
|
|
132
|
-
|
|
133
|
-
stays stable and the attempt number increases. Follow the retry requirements;
|
|
134
|
-
the rejected attempt has not been committed.
|
|
144
|
+
## 6. Status, history and audit
|
|
135
145
|
|
|
136
|
-
|
|
137
|
-
your workspace (see Backtrack section above), then work from the restored
|
|
138
|
-
prompt at the new round number.
|
|
146
|
+
Use only the current twelve tools:
|
|
139
147
|
|
|
140
|
-
|
|
148
|
+
```text
|
|
149
|
+
loopforge_start loopforge_next loopforge_retry
|
|
150
|
+
loopforge_backtrack loopforge_resume loopforge_pause
|
|
151
|
+
loopforge_stop loopforge_status loopforge_history
|
|
152
|
+
loopforge_gate_check loopforge_gate_resolve loopforge_audit
|
|
153
|
+
```
|
|
141
154
|
|
|
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
|
-
|
|
155
|
+
- `loopforge_status({scope: "session", sessionId})` shows the live round. Add
|
|
156
|
+
`detail: "full"` for cognition projections, prompt diagnostics, metrics and
|
|
157
|
+
audit data.
|
|
158
|
+
- `loopforge_status({scope: "loop", loopId})` reads loop-level health and
|
|
159
|
+
audit. `scope: "all"` lists persisted loop summaries (including stopped
|
|
160
|
+
loops for audit/recovery inspection) and accepts no ID.
|
|
161
|
+
- `loopforge_history({loopId, view: "round", round})` reads one persisted
|
|
162
|
+
round. `view: "timeline"` reads events in `event_sequence` order; use
|
|
163
|
+
`fromSequence`, `toSequence` and `limit` (1-200) for pagination.
|
|
164
|
+
- `loopforge_audit({loopId})` is read-only and reports criteria coverage,
|
|
165
|
+
contradictions, evidence availability, unresolved User Gates, regression
|
|
166
|
+
obligations and `sequenceComplete`.
|
|
167
|
+
|
|
168
|
+
The old names `loopforge_list`, `loopforge_health`, `loopforge_inspect`, and
|
|
169
|
+
`loopforge_replay` are not public tools.
|
|
170
|
+
|
|
171
|
+
## 7. Pause and resume
|
|
172
|
+
|
|
173
|
+
Call `loopforge_pause` before an intentional interruption. After a client or
|
|
174
|
+
process restart, call `loopforge_resume` with the saved `loopId`; do not start a
|
|
175
|
+
new loop just because the in-memory session disappeared. Compare the returned
|
|
176
|
+
`stateHash` and `promptHash`, then execute the rebuilt prompt. A loop can be
|
|
177
|
+
resumed only from its persisted vault state.
|
|
178
|
+
|
|
179
|
+
## 8. Prompt levels and projections
|
|
180
|
+
|
|
181
|
+
- **L0**: compact same-round retry with the rejection gap.
|
|
182
|
+
- **L1**: normal continuation with current focus and required evidence.
|
|
183
|
+
- **L2**: full rehydration after the first round, a phase boundary, goal or
|
|
184
|
+
constraint change, stale or contradictory evidence, drift, recovery, or
|
|
185
|
+
repeated low-information rounds.
|
|
186
|
+
|
|
187
|
+
L0/L1/L2 control state density, not reasoning strategy. The prompt compiler
|
|
188
|
+
reads canonical Goal, RoundEvent, EvidenceEnvelope, Constraint, SubGoal and
|
|
189
|
+
GateDecision facts, then derives Phase, Focus, Todo, Handoff, progress and
|
|
190
|
+
diagnostics. Mandatory objective, focus, gate, hard constraints and required
|
|
191
|
+
fixes remain present under a prompt budget.
|
|
192
|
+
|
|
193
|
+
## 9. Workspace and command safety
|
|
194
|
+
|
|
195
|
+
When LoopForge requests verification, run commands in the bound workspace only.
|
|
196
|
+
Use executable plus argument arrays, `shell: false`, timeouts, output limits and
|
|
197
|
+
path-boundary checks. Do not concatenate user-controlled strings into shell
|
|
198
|
+
commands. This is LoopForge's evidence boundary; it does not grant or revoke
|
|
199
|
+
the Agent's ordinary tool permissions.
|
|
200
|
+
|
|
201
|
+
## 10. Long-horizon habits
|
|
202
|
+
|
|
203
|
+
Keep one loop focused on one user objective. Submit one honest report per
|
|
204
|
+
round, preserve criterion and constraint IDs, and include a concrete next
|
|
205
|
+
verification when continuing. Inspect the full state on L2 rounds. Use pause
|
|
206
|
+
before handoff and audit before claiming final completion. LoopForge supports
|
|
207
|
+
long runs through explicit rounds and durable replay, but it does not execute
|
|
208
|
+
rounds in the background for you.
|
|
209
|
+
|
|
210
|
+
## 11. Reliability rules
|
|
211
|
+
|
|
212
|
+
An invalid report is an input error, not a round fact. The runtime leaves the
|
|
213
|
+
current `roundId`, attempt, state and vault unchanged and returns
|
|
214
|
+
`invalid_round_report`; submit a corrected report instead of starting a new
|
|
215
|
+
loop. A persistence error is not recoverable by pretending success: stop and
|
|
216
|
+
retry the operation after the storage boundary is healthy.
|
|
217
|
+
|
|
218
|
+
Evidence capture and recovery are asynchronous. `maxRounds` must be a positive
|
|
219
|
+
integer no greater than the configured policy limit. Corrupt JSON, an invalid
|
|
220
|
+
event format, or a sequence gap returns `storage_corruption`; the runtime never
|
|
221
|
+
sorts, fills, or rewrites damaged history. Terminal enforcement rules track
|
|
222
|
+
their escalation retry independently; the same rule terminates only after its
|
|
223
|
+
guided retry has already been used.
|
|
224
|
+
|
|
225
|
+
When intent drift is reported, use `driftClarification` with a concrete
|
|
226
|
+
explanation and an anchor that exists in the current criteria, constraints or
|
|
227
|
+
observed workspace evidence. Do not send `clarification_accepted: true`.
|
|
228
|
+
Runtime verification owns the clarification streak and any escalation.
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/** @deprecated Use LoopStore from loop-store.js directly.
|
|
2
|
-
*
|
|
3
|
-
* Kept for backward compatibility with modules that still reference
|
|
4
|
-
* VaultBackend as a parameter type. New code should depend on LoopStore. */
|
|
5
|
-
export interface VaultEntry {
|
|
6
|
-
id?: string;
|
|
7
|
-
task_id?: string;
|
|
8
|
-
version_tag?: string;
|
|
9
|
-
is_active?: boolean;
|
|
10
|
-
timestamp?: string;
|
|
11
|
-
user_intent?: string;
|
|
12
|
-
task_type?: string;
|
|
13
|
-
/** @deprecated Use `success` field instead. Kept for reading old vault data. */
|
|
14
|
-
quality_score?: number;
|
|
15
|
-
success?: boolean;
|
|
16
|
-
skill_used?: string;
|
|
17
|
-
loop_id?: string;
|
|
18
|
-
loop_lineage?: Record<string, unknown>;
|
|
19
|
-
loop_objective?: Record<string, unknown> | null;
|
|
20
|
-
execution_feedback?: string;
|
|
21
|
-
task?: string;
|
|
22
|
-
output_summary?: string;
|
|
23
|
-
constraint_violations?: string[];
|
|
24
|
-
tags?: string[];
|
|
25
|
-
full_prompt?: string;
|
|
26
|
-
[key: string]: unknown;
|
|
27
|
-
}
|
|
28
|
-
export interface VaultBackend {
|
|
29
|
-
/** Optional atomic critical section used by storage adapters. */
|
|
30
|
-
withLock?<T>(fn: () => T): T;
|
|
31
|
-
queryEntries(opts?: {
|
|
32
|
-
prefix?: string;
|
|
33
|
-
taskIdPattern?: string;
|
|
34
|
-
feedbackOnly?: boolean;
|
|
35
|
-
}): VaultEntry[];
|
|
36
|
-
appendEntry(entry: VaultEntry): void;
|
|
37
|
-
appendEntries(entries: VaultEntry[]): number;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/backends/interface.ts"],"names":[],"mappings":"AAAA;;;6EAG6E;AAE7E,MAAM,WAAW,UAAU;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAChD,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,iEAAiE;IACjE,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAG7B,YAAY,CAAC,IAAI,CAAC,EAAE;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB,GAAG,UAAU,EAAE,CAAC;IAEjB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IACrC,aAAa,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;CAE9C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../src/backends/interface.ts"],"names":[],"mappings":"AAAA;;;6EAG6E"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/** Enforcement Gate — Layer 2 round-boundary runtime enforcement (v1.13).
|
|
2
|
-
*
|
|
3
|
-
* Pure-function module. Receives the verification gate's findings plus
|
|
4
|
-
* round-level context and decides whether to accept the round, reject it
|
|
5
|
-
* (force the agent to redo), or terminate the loop.
|
|
6
|
-
*
|
|
7
|
-
* This is the "runtime" that prompt-only constraint systems lack.
|
|
8
|
-
* Verification gate detects WHAT is wrong; enforcement gate decides
|
|
9
|
-
* what to DO about it.
|
|
10
|
-
*
|
|
11
|
-
* Decision semantics:
|
|
12
|
-
* - accept: round passes all checks; advance to next round as normal.
|
|
13
|
-
* - reject: agent's self-evaluation or round output is invalid; the
|
|
14
|
-
* agent receives a rejection prompt and must redo the SAME
|
|
15
|
-
* round. Round counter does NOT increment.
|
|
16
|
-
* - terminate: loop has reached an unrecoverable state; stop immediately
|
|
17
|
-
* with stopReason "enforcement_terminated".
|
|
18
|
-
*/
|
|
19
|
-
import type { VaultEntry } from "./backends/interface.js";
|
|
20
|
-
import type { EnforcementResult, SelfEvaluation, VerificationFlag, VerificationResult } from "./protocol.js";
|
|
21
|
-
/** Scan backwards from currentRound to find the most recent clean round.
|
|
22
|
-
* Collects discovered_constraints from skipped rounds along the way.
|
|
23
|
-
* Returns null when no clean round is found within maxDepth. */
|
|
24
|
-
export declare function findSafeRestorePoint(currentRound: number, vaultEntries: VaultEntry[], maxDepth: number): {
|
|
25
|
-
round: number;
|
|
26
|
-
skippedDiscoveries: string[];
|
|
27
|
-
} | null;
|
|
28
|
-
/** Build the backtrack prompt injected at the top of the restored round.
|
|
29
|
-
*
|
|
30
|
-
* v2.13: Includes concrete workspace restore instructions with affected
|
|
31
|
-
* file lists from skipped rounds. The agent must restore the working tree
|
|
32
|
-
* to the clean round's state before proceeding. */
|
|
33
|
-
export declare function buildBacktrackPrompt(fromRound: number, toRound: number, triggerRule: string, skippedDiscoveries: string[],
|
|
34
|
-
/** v2.13: Files changed in the skipped rounds (from evidence snapshots).
|
|
35
|
-
* Used to show the agent exactly what needs to be reverted. */
|
|
36
|
-
skippedFiles?: string[],
|
|
37
|
-
/** v2.13: Git HEAD commit hash at the backtrack point (current HEAD).
|
|
38
|
-
* The agent must discard work back to the clean round's state. */
|
|
39
|
-
_gitHead?: string): string;
|
|
40
|
-
/** Enforce round-boundary rules based on the verification gate's findings
|
|
41
|
-
* and the agent's self-evaluation integrity.
|
|
42
|
-
*
|
|
43
|
-
* Rules run in priority order (R1 → R5). The first rule that fires wins.
|
|
44
|
-
*
|
|
45
|
-
* @param selfEval The agent's self-evaluation for the current round.
|
|
46
|
-
* @param verifyResult The verification gate's output (from verifySelfEvaluation).
|
|
47
|
-
* @param currentRound Current round number (1-based, BEFORE increment).
|
|
48
|
-
* @param vaultEntries Vault entries for this loop (used for progress tracking).
|
|
49
|
-
* @param consecutiveRejections How many consecutive rounds have already been rejected.
|
|
50
|
-
* Starts at 0; increments on each reject; resets on accept.
|
|
51
|
-
*/
|
|
52
|
-
export declare function enforceRound(selfEval: SelfEvaluation, verifyResult: VerificationResult, currentRound: number, vaultEntries: VaultEntry[], consecutiveRejections?: number, skipEvidenceRules?: boolean,
|
|
53
|
-
/** v2.12: Current clarification streak for R7 escalation. */
|
|
54
|
-
driftClarificationStreak?: number): EnforcementResult;
|
|
55
|
-
/** Build a rejection prompt for the agent.
|
|
56
|
-
*
|
|
57
|
-
* The prompt clearly states the round was rejected, why, what the agent
|
|
58
|
-
* must fix, and that the agent must redo the SAME round (not advance).
|
|
59
|
-
*
|
|
60
|
-
* v2.7: Accepts verificationFlags to render a diagnostic "Evidence Gap"
|
|
61
|
-
* section. Each error/warn flag becomes a concrete claim-vs-evidence
|
|
62
|
-
* mismatch statement so the agent knows exactly what to correct rather
|
|
63
|
-
* than retrying blindly.
|
|
64
|
-
*
|
|
65
|
-
* @param currentRound The round number that was rejected (NOT incremented).
|
|
66
|
-
* @param task The original loop task description.
|
|
67
|
-
* @param enforceResult The enforcement decision with reason and fix instructions.
|
|
68
|
-
* @param verificationFlags The verification gate's findings for this round.
|
|
69
|
-
* Used to build the Evidence Gap section. */
|
|
70
|
-
export declare function buildRejectionPrompt(currentRound: number, task: string, enforceResult: EnforcementResult, verificationFlags?: VerificationFlag[]): string;
|
|
71
|
-
//# sourceMappingURL=enforcement-gate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enforcement-gate.d.ts","sourceRoot":"","sources":["../src/enforcement-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AA6DvB;;iEAEiE;AACjE,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,UAAU,EAAE,EAC1B,QAAQ,EAAE,MAAM,GACf;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,IAAI,CAsCxD;AAED;;;;oDAIoD;AACpD,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,kBAAkB,EAAE,MAAM,EAAE;AAC5B;gEACgE;AAChE,YAAY,GAAE,MAAM,EAAO;AAC3B;mEACmE;AACnE,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CA0HR;AA4kBD;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,cAAc,EACxB,YAAY,EAAE,kBAAkB,EAChC,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,UAAU,EAAE,EAC1B,qBAAqB,GAAE,MAAU,EACjC,iBAAiB,UAAQ;AACzB,6DAA6D;AAC7D,wBAAwB,GAAE,MAAU,GACnC,iBAAiB,CA0BnB;AAED;;;;;;;;;;;;;;sEAcsE;AACtE,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,iBAAiB,EAChC,iBAAiB,GAAE,gBAAgB,EAAO,GACzC,MAAM,CA6CR"}
|