feat: implement goal-init and missing goal templates · octo-patch/loop-engineering@1c07972 · GitHub
Skip to content

Commit 1c07972

Browse files
committed
feat: implement goal-init and missing goal templates
1 parent f0623ed commit 1c07972

26 files changed

Lines changed: 879 additions & 13 deletions

‎.test-manual/AGENTS.md‎

Lines changed: 5 additions & 0 deletions

‎.test-manual/GOAL.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Goal: [Insert Goal Title Here]
2+
3+
**Status:** IN_PROGRESS
4+
**Owner:** [Assigned Agent or Human]
5+
**Target Date:** YYYY-MM-DD
6+
7+
## Objective
8+
Describe the main objective of this goal. What are we trying to achieve?
9+
10+
## Acceptance Criteria
11+
- [ ] Criterion 1 (e.g. Unit tests cover X)
12+
- [ ] Criterion 2 (e.g. Integration with Y works)
13+
- [ ] Verified by `goal-verifier` skill
14+
15+
## Scope & Constraints
16+
- What is explicitly OUT of scope?
17+
- Are there budget limits (see `goal-budget.md`)?
18+
- Are there technical constraints?
19+
20+
## Context
21+
Include links to issues, design docs, or relevant slack threads.
22+
23+
---
24+
*Generated by loop-init / goal-init*

‎.test-manual/goal-budget.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Goal Budget
2+
3+
> Bound the execution of a goal to prevent runaway agents.
4+
5+
## Limits
6+
7+
- **Maximum total tokens:** 1,000,000
8+
- **Maximum API calls:** 200
9+
- **Maximum duration:** 24 hours
10+
11+
## Exceedance Policy
12+
If the budget is exceeded, the agent MUST:
13+
1. Halt execution.
14+
2. Update `GOAL.md` status to BLOCKED.
15+
3. Append a failure note to `goal-run-log.md`.
16+
4. Await human intervention.

‎.test-manual/goal-run-log.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Loop Run Log — YOUR_PROJECT
2+
3+
Append one entry per run. Prune entries older than 30 days.
4+
5+
## Format
6+
7+
```json
8+
{
9+
"run_id": "2026-06-09T08:15:00Z",
10+
"pattern": "daily-triage",
11+
"duration_s": 45,
12+
"items_found": 4,
13+
"actions_taken": 1,
14+
"escalations": 0,
15+
"tokens_estimate": 52000,
16+
"outcome": "report-only | fix-proposed | escalated | no-op"
17+
}
18+
```
19+
20+
## Recent Runs
21+
22+
<!-- Loop appends below this line -->

‎PR_DESCRIPTION.md‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## Summary
2+
Replaces exact string matching for error signatures with a highly robust **Character Trigram Jaccard Similarity** algorithm in `loop-context`, ensuring the circuit breaker trips on semantically-similar failures even if the phrasing or wording morphs slightly across iterations.
3+
4+
## Changes
5+
- [ ] New pattern or starter (followed `templates/pattern-template.md` + updated `registry.yaml`)
6+
- [ ] Doc / example improvement
7+
- [x] Tool change (`loop-context`)
8+
- [ ] Story (includes real failure or surprise + lesson)
9+
10+
## Checklist (from CONTRIBUTING)
11+
- [ ] All required sections present for patterns
12+
- [ ] Links work from README, patterns/README, starters/README, docs/index
13+
- [x] No secrets, tokens, internal company URLs
14+
- [ ] `STATE.md*` examples use `.example` suffix
15+
- [ ] Safety-related content references `docs/safety.md`
16+
- [x] Ran `node tools/loop-audit/dist/cli.js .` (or on the starter) and addressed findings
17+
18+
## Testing / Dogfood
19+
- [x] `loop-audit` passes on affected starters or this repo (Scored 100/100 L3)
20+
- [x] Manual review of generated state / skill output (Fully tested with `npm run test` inside `tools/loop-context` - all 49 edge-case and algorithm tests pass cleanly).
21+
22+
## Screenshots / Examples (if UI or command output)
23+
**Running loop-context on slightly morphed failures:**
24+
```bash
25+
$ loop-context --check --stagnation 3 --similarity-threshold 0.85 < run.json
26+
ESCALATE [stagnation] — Same error repeated 3× in a row (threshold 3): "Error: connection timeout on port #". Escalating instead of retrying.
27+
```
28+
29+
---
30+
31+
*This template enforces the high bar this reference is known for.*

‎package.json‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
"test:loop-gate": "cd tools/loop-gate && npm test",
1414
"test:mcp-server": "cd tools/mcp-server && npm test",
1515
"test:loop-worktree": "cd tools/loop-worktree && npm test",
16-
"test:tools": "npm run test:loop-audit && npm run test:loop-init && npm run test:loop-cost && npm run test:loop-sync && npm run test:loop-context && npm run test:loop-gate && npm run test:mcp-server && npm run test:loop-worktree",
17-
"build:tools": "cd tools/loop-audit && npm run build && cd ../loop-init && npm run build && cd ../loop-cost && npm run build && cd ../loop-sync && npm run build && cd ../loop-context && npm run build && cd ../loop-gate && npm run build && cd ../mcp-server && npm run build && cd ../loop-worktree && npm run build",
16+
"test:goal-init": "cd tools/goal-init && npm test",
17+
"test:tools": "npm run test:loop-audit && npm run test:loop-init && npm run test:loop-cost && npm run test:loop-sync && npm run test:loop-context && npm run test:loop-gate && npm run test:mcp-server && npm run test:loop-worktree && npm run test:goal-init",
18+
"build:tools": "cd tools/loop-audit && npm run build && cd ../loop-init && npm run build && cd ../loop-cost && npm run build && cd ../loop-sync && npm run build && cd ../loop-context && npm run build && cd ../loop-gate && npm run build && cd ../mcp-server && npm run build && cd ../loop-worktree && npm run build && cd ../goal-init && npm run build",
1819
"contributors:generate": "node scripts/generate-contributors.mjs",
1920
"contributors:check": "node scripts/generate-contributors.mjs --check"
2021
},

‎scratch.js‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { errorSignature } from './tools/loop-context/dist/context-manager.js';
2+
3+
function getTrigrams(str) {
4+
const trigrams = new Set();
5+
const padded = ` ${str.toLowerCase()} `;
6+
for (let i = 0; i < padded.length - 2; i++) {
7+
trigrams.add(padded.substring(i, i + 3));
8+
}
9+
return trigrams;
10+
}
11+
12+
function calculateSimilarity(a, b) {
13+
if (a === b) return 1.0;
14+
const setA = getTrigrams(a);
15+
const setB = getTrigrams(b);
16+
if (setA.size === 0 && setB.size === 0) return 1.0;
17+
if (setA.size === 0 || setB.size === 0) return 0.0;
18+
19+
let intersection = 0;
20+
for (const item of setA) {
21+
if (setB.has(item)) intersection++;
22+
}
23+
const union = setA.size + setB.size - intersection;
24+
return intersection / union;
25+
}
26+
27+
const e1 = errorSignature('Error: timeout on port 8080');
28+
const e2 = errorSignature('Error: timed out waiting for 8080');
29+
const e3 = errorSignature('Error: connection timeout on port 8080');
30+
console.log('e1:', e1);
31+
console.log('e2:', e2);
32+
console.log('e3:', e3);
33+
console.log('e1 vs e2:', calculateSimilarity(e1, e2));
34+
console.log('e1 vs e3:', calculateSimilarity(e1, e3));
35+
console.log('e2 vs e3:', calculateSimilarity(e2, e3));

‎scripts/ci-validate-gates.sh‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ cd tools/loop-sync
6565
npm ci
6666
npm test
6767

68+
echo "Building and testing goal-init…"
69+
cd ../goal-init
70+
npm ci
71+
npm test
72+
6873
echo "Building and testing loop-context…"
6974
cd ../loop-context
7075
npm ci

‎templates/GOAL.md.template‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Goal: [Insert Goal Title Here]
2+
3+
**Status:** IN_PROGRESS
4+
**Owner:** [Assigned Agent or Human]
5+
**Target Date:** YYYY-MM-DD
6+
7+
## Objective
8+
Describe the main objective of this goal. What are we trying to achieve?
9+
10+
## Acceptance Criteria
11+
- [ ] Criterion 1 (e.g. Unit tests cover X)
12+
- [ ] Criterion 2 (e.g. Integration with Y works)
13+
- [ ] Verified by `goal-verifier` skill
14+
15+
## Scope & Constraints
16+
- What is explicitly OUT of scope?
17+
- Are there budget limits (see `goal-budget.md`)?
18+
- Are there technical constraints?
19+
20+
## Context
21+
Include links to issues, design docs, or relevant slack threads.
22+
23+
---
24+
*Generated by loop-init / goal-init*

‎templates/SKILL.md.goal-scoper‎

Lines changed: 12 additions & 0 deletions

0 commit comments

Comments
 (0)