ai-engineering-loop 1.16.0 → 1.17.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.
Files changed (38) hide show
  1. package/.agents/skills/ai-engineering-loop/references/loop-deliver.md +2 -1
  2. package/.agents/skills/ai-engineering-loop/references/loop-goal.md +1 -0
  3. package/.agents/skills/ai-engineering-loop/references/loop-maker.md +1 -0
  4. package/.claude/skills/ai-engineering-loop/references/loop-deliver.md +2 -1
  5. package/.claude/skills/ai-engineering-loop/references/loop-goal.md +1 -0
  6. package/.claude/skills/ai-engineering-loop/references/loop-maker.md +1 -0
  7. package/CHANGELOG.md +32 -0
  8. package/README.md +24 -22
  9. package/adapters/dot/gitlab.md +6 -0
  10. package/adapters/github/pull-request.md +5 -0
  11. package/adapters/gitlab/merge-request.md +5 -0
  12. package/adapters/quality/skills/task-impact-inquiry/SKILL.md +2 -0
  13. package/bin/ai-engineering-loop.js +294 -4
  14. package/core/blast-radius-map.md +37 -0
  15. package/core/learnings.md +24 -0
  16. package/core/pr-receipt.md +35 -0
  17. package/core/runtime-safety.md +24 -0
  18. package/lib/cli-args.js +5 -1
  19. package/lib/doctor.js +4 -1
  20. package/lib/gates.js +39 -0
  21. package/lib/guard-hooks.js +115 -0
  22. package/lib/guard.js +336 -0
  23. package/lib/hosts/commands.js +4 -3
  24. package/lib/hosts/doctor.js +3 -3
  25. package/lib/hosts/registry.js +21 -2
  26. package/lib/hosts/table.js +6 -4
  27. package/lib/impact-map.js +501 -0
  28. package/lib/learn.js +303 -0
  29. package/lib/receipt.js +362 -0
  30. package/lib/safe-context.js +14 -0
  31. package/lib/smart-context.js +21 -0
  32. package/package.json +1 -1
  33. package/schemas/delivery.schema.json +11 -1
  34. package/schemas/finding-ledger.schema.json +2 -1
  35. package/schemas/goal-contract.schema.json +9 -0
  36. package/schemas/impact-map.schema.json +78 -0
  37. package/schemas/learnings.schema.json +47 -0
  38. package/schemas/receipt.schema.json +102 -0
@@ -237,6 +237,17 @@ function createContextPack(rootDir, { runId, stage, files, profile } = {}) {
237
237
  content: redacted.text
238
238
  });
239
239
  }
240
+ // Project learnings (#61) for Maker and DA, inside this stage's budget.
241
+ const learned = stage === 'judge'
242
+ ? { learnings: [], estimatedTokens: 0 }
243
+ : require('./learn.js').selectLearnings(rootDir, {
244
+ files: entries.map((entry) => entry.path),
245
+ budgetTokens: Math.min(
246
+ limits.maxEstimatedTokens * require('./learn.js').LEARNINGS_BUDGET_SHARE,
247
+ limits.maxEstimatedTokens - estimatedTokens
248
+ )
249
+ });
250
+ estimatedTokens += learned.estimatedTokens;
240
251
  assertBudgetAvailable(rootDir, { runId: run.runId, estimatedTokens });
241
252
 
242
253
  const pack = {
@@ -249,6 +260,8 @@ function createContextPack(rootDir, { runId, stage, files, profile } = {}) {
249
260
  limits,
250
261
  totalBytes,
251
262
  estimatedTokens,
263
+ learningTokens: learned.estimatedTokens,
264
+ learnings: learned.learnings,
252
265
  entries
253
266
  };
254
267
  const packPath = path.join(runsDir(rootDir), run.runId, 'context', `${stage}.json`);
@@ -269,6 +282,7 @@ function contextPackSummary(result) {
269
282
  files: result.pack.entries.length,
270
283
  totalBytes: result.pack.totalBytes,
271
284
  estimatedTokens: result.pack.estimatedTokens,
285
+ learnings: (result.pack.learnings || []).length,
272
286
  redactions: result.pack.entries.reduce((sum, entry) => sum + entry.redactions.length, 0),
273
287
  truncatedFiles: result.pack.entries.filter((entry) => entry.truncated).length
274
288
  };
@@ -473,6 +473,14 @@ function boundedHunks(file, limits, remainingBytes) {
473
473
  return { hunks, includedBytes, truncated };
474
474
  }
475
475
 
476
+ // Blast-radius drift from verify (#71): the Devil's Advocate sees which
477
+ // changed files were outside the impact map.
478
+ function impactDriftSummary(rootDir, runId) {
479
+ const drift = require('./impact-map.js').loadImpactDrift(rootDir, runId);
480
+ if (!drift) return null;
481
+ return { mapStatus: drift.mapStatus, outOfMap: (drift.outOfMap || []).slice(0, 50) };
482
+ }
483
+
476
484
  function createDiffHunkPack(rootDir, { runId, base = 'HEAD', profile, includeIgnored = false } = {}) {
477
485
  const run = resolveRun(rootDir, runId);
478
486
  const policy = loadPolicy(rootDir);
@@ -514,6 +522,16 @@ function createDiffHunkPack(rootDir, { runId, base = 'HEAD', profile, includeIgn
514
522
  if (estimatedTokens > contextLimits.maxEstimatedTokens) {
515
523
  throw smartContextError(`${reviewProfile} diff hunk pack exceeds devil-advocate token budget`, 'DIFF_PACK_TOKEN_LIMIT');
516
524
  }
525
+ // Project learnings (#61) the Devil's Advocate should not have to rediscover.
526
+ const { LEARNINGS_BUDGET_SHARE, selectLearnings } = require('./learn.js');
527
+ const learned = selectLearnings(rootDir, {
528
+ files: changedPaths,
529
+ budgetTokens: Math.min(
530
+ contextLimits.maxEstimatedTokens * LEARNINGS_BUDGET_SHARE,
531
+ contextLimits.maxEstimatedTokens - estimatedTokens
532
+ )
533
+ });
534
+ estimatedTokens += learned.estimatedTokens;
517
535
  assertBudgetAvailable(rootDir, { runId: run.runId, estimatedTokens });
518
536
  const pack = {
519
537
  schemaVersion: 1,
@@ -536,6 +554,8 @@ function createDiffHunkPack(rootDir, { runId, base = 'HEAD', profile, includeIgn
536
554
  focusPaths
537
555
  },
538
556
  unresolvedFindings: unresolved,
557
+ impactDrift: impactDriftSummary(rootDir, run.runId),
558
+ learnings: learned.learnings,
539
559
  files
540
560
  };
541
561
  const packPath = path.join(runsDir(rootDir), run.runId, 'context', 'diff-hunks.json');
@@ -617,6 +637,7 @@ function smartContextSummary(result) {
617
637
  truncated: result.pack.truncated,
618
638
  unresolvedFindings: result.pack.unresolvedFindings.length,
619
639
  ignoredPaths: result.pack.reviewDelta?.ignoredPaths?.length || 0,
640
+ impactDrift: result.pack.impactDrift || null,
620
641
  reviewBudget: result.pack.reviewBudget
621
642
  };
622
643
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-engineering-loop",
3
- "version": "1.16.0",
3
+ "version": "1.17.0",
4
4
  "description": "A visual workspace that helps AI coding agents plan, build, review, and ship reliable software.",
5
5
  "main": "bin/ai-engineering-loop.js",
6
6
  "bin": {
@@ -9,7 +9,17 @@
9
9
  "runId": { "type": "string", "minLength": 1 },
10
10
  "destination": { "type": "string", "minLength": 1 },
11
11
  "summary": { "type": "string", "minLength": 1 },
12
- "humanApproved": { "type": "boolean" }
12
+ "humanApproved": { "type": "boolean" },
13
+ "approvedBy": { "type": "string" },
14
+ "receipt": {
15
+ "description": "Proof-carrying PR receipt written by deliver (#70)",
16
+ "type": "object",
17
+ "required": ["path", "digest"],
18
+ "properties": {
19
+ "path": { "type": "string", "minLength": 1 },
20
+ "digest": { "type": "string", "pattern": "^[a-f0-9]{64}$" }
21
+ }
22
+ }
13
23
  },
14
24
  "additionalProperties": true
15
25
  }
@@ -17,7 +17,8 @@
17
17
  "axis": { "enum": ["spec", "standards"] },
18
18
  "severity": { "enum": ["BLOCKER", "HIGH", "MEDIUM", "LOW"] },
19
19
  "validity": { "enum": ["VALID", "INVALID"] },
20
- "disposition": { "enum": ["STRONG", "ACCEPTABLE", "WEAK"] }
20
+ "disposition": { "enum": ["STRONG", "ACCEPTABLE", "WEAK"] },
21
+ "source": { "description": "Producer of a CLI-generated finding, e.g. impact-map for blast-radius drift", "type": "string" }
21
22
  },
22
23
  "additionalProperties": true
23
24
  }
@@ -26,6 +26,15 @@
26
26
  },
27
27
  "additionalProperties": true
28
28
  }
29
+ },
30
+ "scope": {
31
+ "description": "Optional file scope frozen with the Goal (#59). Absent = no path enforcement. Globs: ** crosses directories, * stays in one segment, a trailing / is a directory prefix.",
32
+ "type": "object",
33
+ "properties": {
34
+ "allowedPaths": { "type": "array", "items": { "type": "string", "minLength": 1 } },
35
+ "deniedPaths": { "type": "array", "items": { "type": "string", "minLength": 1 } }
36
+ },
37
+ "additionalProperties": false
29
38
  }
30
39
  },
31
40
  "additionalProperties": true
@@ -0,0 +1,78 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/egagofur/ai-engineering-loop/schemas/impact-map.schema.json",
4
+ "title": "AI Engineering Loop Blast-Radius Impact Map",
5
+ "type": "object",
6
+ "required": ["schemaVersion", "runId", "goalHash", "status", "files", "modules", "endpoints", "dbTables", "tests"],
7
+ "properties": {
8
+ "schemaVersion": { "const": 1 },
9
+ "runId": { "type": "string", "minLength": 1 },
10
+ "goalHash": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
11
+ "status": { "enum": ["DRAFT", "CONFIRMED", "SKIPPED"] },
12
+ "generator": { "type": "string" },
13
+ "generatedAt": { "type": "string" },
14
+ "keywords": { "type": "array", "items": { "type": "string" } },
15
+ "files": { "type": "array", "items": { "$ref": "#/$defs/pathEntry" } },
16
+ "modules": { "type": "array", "items": { "$ref": "#/$defs/namedEntry" } },
17
+ "endpoints": {
18
+ "type": "array",
19
+ "items": {
20
+ "allOf": [{ "$ref": "#/$defs/pathEntry" }],
21
+ "required": ["method", "route"],
22
+ "properties": {
23
+ "method": { "type": "string" },
24
+ "route": { "type": "string" }
25
+ }
26
+ }
27
+ },
28
+ "dbTables": {
29
+ "type": "array",
30
+ "items": {
31
+ "allOf": [{ "$ref": "#/$defs/namedEntry" }],
32
+ "required": ["kind"],
33
+ "properties": { "kind": { "enum": ["table", "migration"] }, "path": { "type": "string" } }
34
+ }
35
+ },
36
+ "tests": { "type": "array", "items": { "$ref": "#/$defs/pathEntry" } },
37
+ "scope": {
38
+ "oneOf": [
39
+ { "type": "null" },
40
+ {
41
+ "type": "object",
42
+ "required": ["allowedPaths"],
43
+ "properties": { "allowedPaths": { "type": "array", "items": { "type": "string", "minLength": 1 } } }
44
+ }
45
+ ]
46
+ },
47
+ "confirmedBy": { "type": "string" },
48
+ "confirmedAt": { "type": "string" },
49
+ "skipReason": { "type": "string", "minLength": 1, "maxLength": 500 },
50
+ "skippedBy": { "type": "string" },
51
+ "skippedAt": { "type": "string" }
52
+ },
53
+ "allOf": [
54
+ { "if": { "properties": { "status": { "const": "SKIPPED" } } }, "then": { "required": ["skipReason"] } },
55
+ { "if": { "properties": { "status": { "const": "CONFIRMED" } } }, "then": { "required": ["scope", "confirmedBy"] } }
56
+ ],
57
+ "$defs": {
58
+ "pathEntry": {
59
+ "type": "object",
60
+ "required": ["path", "confidence", "reason"],
61
+ "properties": {
62
+ "path": { "type": "string", "minLength": 1 },
63
+ "confidence": { "type": "number", "minimum": 0, "maximum": 1 },
64
+ "reason": { "type": "string", "minLength": 1 }
65
+ }
66
+ },
67
+ "namedEntry": {
68
+ "type": "object",
69
+ "required": ["name", "confidence", "reason"],
70
+ "properties": {
71
+ "name": { "type": "string", "minLength": 1 },
72
+ "confidence": { "type": "number", "minimum": 0, "maximum": 1 },
73
+ "reason": { "type": "string", "minLength": 1 }
74
+ }
75
+ }
76
+ },
77
+ "additionalProperties": true
78
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/egagofur/ai-engineering-loop/schemas/learnings.schema.json",
4
+ "title": "AI Engineering Loop Project Learnings",
5
+ "type": "object",
6
+ "required": ["schemaVersion", "generator", "sourceRuns", "entries", "suppressed"],
7
+ "properties": {
8
+ "schemaVersion": { "const": 1 },
9
+ "generator": { "type": "string" },
10
+ "sourceRuns": { "type": "integer", "minimum": 0 },
11
+ "latestRunId": { "type": ["string", "null"] },
12
+ "entries": {
13
+ "type": "array",
14
+ "items": {
15
+ "type": "object",
16
+ "required": ["id", "axis", "severity", "lesson", "locations", "occurrences", "runIds", "firstRunId", "lastRunId"],
17
+ "properties": {
18
+ "id": { "type": "string", "pattern": "^L-[a-f0-9]{10}$" },
19
+ "axis": { "enum": ["spec", "standards"] },
20
+ "severity": { "enum": ["BLOCKER", "HIGH", "MEDIUM", "LOW"] },
21
+ "lesson": { "type": "string", "minLength": 1, "maxLength": 300 },
22
+ "locations": { "type": "array", "items": { "type": "string" } },
23
+ "occurrences": { "type": "integer", "minimum": 1 },
24
+ "runIds": { "type": "array", "minItems": 1, "items": { "type": "string" } },
25
+ "firstRunId": { "type": "string" },
26
+ "lastRunId": { "type": "string" },
27
+ "lastSeenAt": { "type": "string" },
28
+ "supersededBy": { "description": "Set by a human; the next learn run suppresses the entry", "type": "string" }
29
+ }
30
+ }
31
+ },
32
+ "suppressed": {
33
+ "type": "array",
34
+ "items": {
35
+ "type": "object",
36
+ "required": ["id", "reason"],
37
+ "properties": {
38
+ "id": { "type": "string" },
39
+ "reason": { "enum": ["files-removed", "stale", "superseded"] },
40
+ "supersededBy": { "type": "string" },
41
+ "lastRunId": { "type": ["string", "null"] }
42
+ }
43
+ }
44
+ }
45
+ },
46
+ "additionalProperties": true
47
+ }
@@ -0,0 +1,102 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/egagofur/ai-engineering-loop/schemas/receipt.schema.json",
4
+ "title": "AI Engineering Loop Proof-Carrying PR Receipt",
5
+ "type": "object",
6
+ "required": ["schemaVersion", "runId", "generatedAt", "host", "base", "head", "goal", "acceptanceCriteria", "verification", "review", "guard", "artifacts", "digest"],
7
+ "properties": {
8
+ "schemaVersion": { "const": 1 },
9
+ "runId": { "type": "string", "minLength": 1 },
10
+ "generatedAt": { "type": "string", "minLength": 1 },
11
+ "aelVersion": { "type": ["string", "null"] },
12
+ "host": {
13
+ "type": "object",
14
+ "required": ["id"],
15
+ "properties": { "id": { "type": "string" }, "model": { "type": ["string", "null"] } }
16
+ },
17
+ "base": { "type": "object", "required": ["sha"], "properties": { "sha": { "type": ["string", "null"] } } },
18
+ "head": { "type": "object", "required": ["sha"], "properties": { "sha": { "type": ["string", "null"] } } },
19
+ "goal": {
20
+ "type": "object",
21
+ "required": ["path", "sha256", "contentHash", "version", "objective"],
22
+ "properties": {
23
+ "path": { "type": "string", "pattern": "^[^/]" },
24
+ "sha256": { "$ref": "#/$defs/sha256" },
25
+ "contentHash": { "$ref": "#/$defs/sha256" },
26
+ "version": { "type": "integer", "minimum": 1 },
27
+ "objective": { "type": "string" }
28
+ }
29
+ },
30
+ "acceptanceCriteria": {
31
+ "type": "array",
32
+ "minItems": 1,
33
+ "items": {
34
+ "type": "object",
35
+ "required": ["id", "statement", "status", "evidence"],
36
+ "properties": {
37
+ "id": { "type": "string", "pattern": "^AC-[0-9]+$" },
38
+ "statement": { "type": "string" },
39
+ "evidenceRequired": { "type": "string" },
40
+ "status": { "enum": ["PASS", "MISSING"] },
41
+ "missing": { "type": "array", "items": { "type": "string" } },
42
+ "evidence": {
43
+ "type": "array",
44
+ "items": {
45
+ "type": "object",
46
+ "required": ["type"],
47
+ "properties": {
48
+ "type": { "enum": ["command", "claim", "link"] },
49
+ "command": { "type": "string" },
50
+ "exitCode": { "type": ["integer", "null"] },
51
+ "outputSha256": { "$ref": "#/$defs/sha256" },
52
+ "url": { "type": "string", "pattern": "^https?://" }
53
+ }
54
+ }
55
+ }
56
+ }
57
+ }
58
+ },
59
+ "verification": {
60
+ "type": "object",
61
+ "required": ["diffHash", "commands"],
62
+ "properties": {
63
+ "diffHash": { "type": "string" },
64
+ "gitRevision": { "type": "string" },
65
+ "commands": { "type": "array" },
66
+ "coverage": { "type": ["object", "null"], "additionalProperties": { "type": "number" } }
67
+ }
68
+ },
69
+ "review": {
70
+ "type": "object",
71
+ "required": ["findings", "verdict"],
72
+ "properties": {
73
+ "findings": { "type": "object", "required": ["total", "valid", "blocking"] },
74
+ "verdict": {
75
+ "type": "object",
76
+ "required": ["verdict"],
77
+ "properties": { "verdict": { "enum": ["PASS", "ITERATE", "ESCALATE"] } }
78
+ }
79
+ }
80
+ },
81
+ "impact": { "type": ["object", "null"] },
82
+ "guard": { "type": "object", "required": ["warn", "block"] },
83
+ "artifacts": {
84
+ "type": "array",
85
+ "items": {
86
+ "type": "object",
87
+ "required": ["name", "path", "sha256"],
88
+ "properties": {
89
+ "name": { "type": "string" },
90
+ "path": { "type": "string", "pattern": "^[^/]" },
91
+ "sha256": { "$ref": "#/$defs/sha256" }
92
+ }
93
+ }
94
+ },
95
+ "digest": { "$ref": "#/$defs/sha256" },
96
+ "signature": { "description": "Optional detached signature of digest (not produced yet)", "type": "string" }
97
+ },
98
+ "$defs": {
99
+ "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" }
100
+ },
101
+ "additionalProperties": true
102
+ }