Skip to content

Commit 00fc059

Browse files
authored
Add 10 cognition-introspection patterns (204 -> 214) (#5)
* Add 6 patterns from Liu et al. 2025 + Anthropic, new cognition-introspection category, redundancy fixes, patterns.graph.json # Patterns added (6, catalog 198 → 204) From Liu et al., "Agent design pattern catalogue", J. Syst. Softw. 220, 112278 (https://doi.org/10.1016/j.jss.2024.112278): - passive-goal-creator (planning-control-flow) - proactive-goal-creator (planning-control-flow) - prompt-response-optimiser (structure-data) - voting-based-cooperation (multi-agent) - tool-agent-registry (tool-use-environment) From Anthropic, "Building Effective Agents" (https://www.anthropic.com/research/building-effective-agents): - augmented-llm (tool-use-environment) — the foundational LLM + tools + retrieval + memory block Liu / Anthropic references added to 14 existing patterns that map to their catalogues (evaluator-optimizer, react, human-in-the-loop, agent-as-judge, translation-layer, tool-discovery, input-output-guardrails, tree-of-thoughts, plan-and-execute, naive-rag, self-refine, reflection, debate, role-assignment). # New category: cognition-introspection Reorganise 9 patterns covering self-awareness, affect, transitional state, and dream/consolidation cycles into a dedicated category: awareness, dream-consolidation-cycle, emotional-state-persistence, interrupt-resumable-thought, intra-agent-memo-scheduling, mode-adaptive-cadence, preoccupation-tracking, self-archaeology, world-model-separation. Adds entries in schema.json (enum), docs/taxonomy.md, .github/scripts/render_html.py (CAT_LABEL). # Redundancy fixes from a graph audit - Drop bogus alias: lineage-tracking no longer claims "Prompt Versioning" as an alias (it's a different first-class pattern). - goal-decomposition ↔ least-to-most: edge changed from alternative-to to complements (they sit at different layers — planner architecture vs prompting tactic, usable together). - Add explicit "Distinct from X:" boundary lines to the Context slot of tool-discovery ↔ tool-agent-registry and orchestrator-workers ↔ supervisor, where adjacent patterns sit close to each other. - Mirror/inverse edges added across 26 pattern pairs so the typed graph balances (lint A4 passes). - Constrains slot reworded for proactive-goal-creator and voting-based-cooperation to use explicit restriction wording. # New derived artefact: patterns.graph.json A typed-graph view of the catalog (nodes = patterns; edges = related[] relations). 204 nodes, 1068 edges. Built by .github/scripts/build_graph.py from patterns-src/ shards or patterns.json. Patterns.graph.schema.json defines the shape. The .json output is gitignored alongside patterns.json (both are derived from patterns-src/). # Source verification All 6 new patterns verified against upstream sources and marked verified=true in verification-todo.json. Per-aspect walkthrough recorded: intent <35 words, context/problem/solution prose match source, constrains restriction-shaped, example_scenario + diagram + applicability populated, URLs alive (incl. fixing Bedrock URL from old advanced-prompts-configure to canonical prompt-management page), no undefined jargon, edges balance. # Lint All 15 rules pass (A6.3 URL liveness occasionally flags arxiv on transient DNS failure — URLs content-verified alive on retry). * Add 10 cognition-introspection patterns (204 -> 214, 14 categories) # Patterns added (10, all in cognition-introspection) - open-question-tension-store append-only ledger of unresolved pulls driving inquiry; intrusiveness gates ask-now vs store - cognitive-move-selector idle-tick router over a small agent-vetted menu of named moves - parallel-voice-proposer multi-voice candidates in one call, self-selected, losers logged as audit - pre-generative-loop-gate pre-tick divergence detection that injects a steering hint, not a veto - multi-axis-promotion-scoring six-axis weighted gate for short-to- long memory tier promotion; consolidation weighted over frequency - cluster-capped-insight-store mechanical mtime-based dedup of insight files per stem-token cluster - meditation-mode runtime mode: external I/O paused, inner-only tool allowlist, bounded window with self/operator exit - partial-output-salvage tmp+rename stream-to-disk + typed recovery marker propagates into the next prompt - typed-tool-loop-detector dispatch-boundary veto with five typed failure modes and per-tool caps; returns a formatted refusal - affect-coupled-plan-lifecycle bounded affect deltas on plan events plus age-bucketed stale-pain # Supporting changes - 16 reverse edges added across 6 other shards so symmetric/inverse relations stay paired (A4 lint passes) - 10 verification-todo entries appended (sort order preserved by id) - INDEX.md regenerated; Cognition & Introspection now lists 19 patterns (10 new + 9 migrated by d5ba975) - README.md count: 179 -> 214, 13 -> 14 categories, 850 -> 1118 edges - pages.yml landing page count: 179 -> 214 - lint.py allowlist extended for patterns.graph.schema.json (cleared pre-existing A2.2 carried in from d5ba975) # Lint All 15 lint rules pass; URL liveness clean on all 22 new references.
1 parent ef62fc7 commit 00fc059

69 files changed

Lines changed: 7823 additions & 3615 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/scripts/build_graph.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/usr/bin/env python3
2+
"""Generate patterns.graph.json — a derived, machine-readable view of the catalog as a typed graph.
3+
4+
Nodes: one per pattern (id, name, category, status_in_practice, aliases).
5+
Edges: one per related[] entry (source, target, relation).
6+
7+
Consumers (graph queries, CI checks, architecture review tools) can build on this without
8+
parsing the full pattern shapes. Source of truth remains patterns-src/ shards / patterns.json.
9+
10+
Run locally: python3 .github/scripts/build_graph.py [out_dir]
11+
Reads: patterns-src/*.json (via build_patterns_json structure) or patterns.json if present.
12+
Writes: <out_dir>/patterns.graph.json (default: repo root)
13+
"""
14+
from __future__ import annotations
15+
16+
import json
17+
import sys
18+
from datetime import date
19+
from pathlib import Path
20+
21+
ROOT = Path(__file__).resolve().parent.parent.parent
22+
SRC_PATTERNS_JSON = ROOT / "patterns.json"
23+
SRC_DIR = ROOT / "patterns-src"
24+
25+
26+
def load_patterns() -> tuple[list[dict], str, str]:
27+
"""Prefer patterns.json if available; else build from shards in patterns-src/."""
28+
if SRC_PATTERNS_JSON.exists():
29+
data = json.loads(SRC_PATTERNS_JSON.read_text())
30+
return data["patterns"], data.get("version", "0.0.0"), data.get("license", "CC-BY-4.0")
31+
patterns: list[dict] = []
32+
seen_ids: set[str] = set()
33+
for shard_path in sorted(SRC_DIR.glob("*.json")):
34+
shard = json.loads(shard_path.read_text())
35+
for p in shard["patterns"]:
36+
if p["id"] in seen_ids:
37+
raise SystemExit(f"duplicate pattern id: {p['id']}")
38+
seen_ids.add(p["id"])
39+
patterns.append(p)
40+
patterns.sort(key=lambda p: (p["category"], p["id"]))
41+
return patterns, "0.0.0", "CC-BY-4.0"
42+
43+
44+
def build(out_dir: Path) -> None:
45+
out_dir.mkdir(parents=True, exist_ok=True)
46+
patterns, version, license_ = load_patterns()
47+
48+
nodes = [
49+
{
50+
"id": p["id"],
51+
"name": p["name"],
52+
"category": p["category"],
53+
"status": p.get("status_in_practice", "unknown"),
54+
"aliases": p.get("aliases", []),
55+
}
56+
for p in patterns
57+
]
58+
59+
seen_ids = {p["id"] for p in patterns}
60+
edges = [
61+
{
62+
"source": p["id"],
63+
"target": r["pattern"],
64+
"relation": r["relation"],
65+
}
66+
for p in patterns
67+
for r in p.get("related", [])
68+
if r["pattern"] in seen_ids
69+
]
70+
71+
out = {
72+
"$schema": "./patterns.graph.schema.json",
73+
"version": version,
74+
"updated": date.today().isoformat(),
75+
"license": license_,
76+
"source": "patterns.json",
77+
"node_count": len(nodes),
78+
"edge_count": len(edges),
79+
"nodes": nodes,
80+
"edges": edges,
81+
}
82+
out_path = out_dir / "patterns.graph.json"
83+
out_path.write_text(json.dumps(out, indent=2, ensure_ascii=False) + "\n")
84+
print(f"wrote {out_path.relative_to(ROOT)} ({len(nodes)} nodes, {len(edges)} edges)")
85+
86+
87+
def main() -> None:
88+
out_dir = Path(sys.argv[1]) if len(sys.argv) > 1 else ROOT
89+
build(out_dir)
90+
91+
92+
if __name__ == "__main__":
93+
main()

.github/scripts/lint.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ def rule_a2() -> list[Violation]:
266266
"glossary.schema.json",
267267
"verification-todo.json",
268268
"verification-todo.schema.json",
269+
"patterns.graph.schema.json",
269270
}
270271
allowed_dirs = {"patterns-src", "patterns", "docs", ".github"}
271272
for f in root_files:

.github/scripts/render_html.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"governance-observability": "Governance & Observability",
3434
"structure-data": "Structure & Data",
3535
"streaming-ux": "Streaming & UX",
36+
"cognition-introspection": "Cognition & Introspection",
3637
"anti-patterns": "Anti-Patterns",
3738
}
3839

.github/workflows/pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
<h1>Agentic Patterns Catalog</h1>
5858
<p>Machine-readable reference of agentic design patterns in GoF/POSA form.</p>
5959
<ul>
60-
<li><a href="patterns/"><code>patterns/</code></a> &mdash; browse the 179 patterns (rendered HTML, Mermaid diagrams)</li>
60+
<li><a href="patterns/"><code>patterns/</code></a> &mdash; browse the 214 patterns (rendered HTML, Mermaid diagrams)</li>
6161
<li><a href="recipes/"><code>recipes/</code></a> &mdash; browse the named cross-category compositions</li>
6262
<li><a href="frameworks/"><code>frameworks/</code></a> &mdash; browse the framework coverage matrix</li>
6363
</ul>

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ NOTES.md
2626
SCRATCH.md
2727
TODO.local.md
2828

29-
# Generated build artifact — patterns-src/ is the source of truth
29+
# Generated build artifacts — patterns-src/ is the source of truth
3030
patterns.json
31+
patterns.graph.json

0 commit comments

Comments
 (0)