Skip to content

feat: v2 pilot — chain_of_responsibility as module + engine support - #17

Merged
SuperElectron merged 4 commits into
stagingfrom
feat/v2-pilot-chain-of-responsibility
Aug 27, 2026
Merged

feat: v2 pilot — chain_of_responsibility as module + engine support#17
SuperElectron merged 4 commits into
stagingfrom
feat/v2-pilot-chain-of-responsibility

Conversation

@SuperElectron

Copy link
Copy Markdown
Owner

Phase 0 of the patterns-as-modules refactor (plan of record: .cache/plan.md, local).

What

  • chain_of_responsibility rebuilt to the v2 module template: pattern/ (generic Chain[Req, Res], Handler, explicit unhandled policy, insert/remove), docs/{fundamentals,implementation,examples}.md (classic-form contrast absorbed from the old GoF-style file), examples/ticket_escalation/ mini-project importing the pattern, isolated tests. Old naive.py/pythonic.py/real_world.py deleted.
  • Engine: src/design_patterns_mcpsrc/design_patterns/mcp (top-level mcp collides with the MCP SDK); dual-shape catalog loader with strict module-shape validation (half-migrations fail CI); sandbox runs example packages (python -I -m, scrubbed env, 10s/64KB); new MCP tools get_pattern_docs / list_examples / run_example / read_source + pattern://<id>/docs/<doc> resources. Legacy tools unchanged for the 31 un-migrated units.

Review

Full adversarial review pass (sandbox trust contract probed and held; 3 HIGH + 6 MEDIUM findings fixed and re-verified against a live MCP client; verdict merge-ready).

Verification

make check green: ruff, mypy --strict (211 files), 281 tests, readme table current. Real-unit smoke: example runs via module path and through the sandboxed run_example tool.

🤖 Generated with Claude Code

SuperElectron and others added 4 commits August 27, 2026 11:24
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Pilot for the patterns-as-modules refactor (.cache/plan.md):
- chain_of_responsibility rebuilt: pattern/ (Chain, Handler), docs/
  {fundamentals,implementation,examples}.md, examples/ticket_escalation/,
  isolated tests; naive/pythonic/real_world files removed
- src/design_patterns_mcp -> src/design_patterns/mcp (top-level 'mcp'
  collides with the MCP SDK)
- loader: dual-shape support, strict validation for module-shape units
- sandbox: run example packages (python -I -m, scrubbed env, 10s/64KB)
- MCP tools: get_pattern_docs, list_examples, run_example, read_source
  + pattern://<id>/docs/<doc> resources

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ict half-migration validation

- recommend_pattern/get_pattern/instructions/prompts branch on unit shape
- Chain.handle_or no longer swallows nested UnhandledRequestError; adds
  insert/remove for ordered-mutation
- loader: any of pattern|docs|examples claims module shape (half-migrations
  fail CI); stale legacy files in module units are errors; examples/__init__.py
  validated
- resource errors explain themselves; get_pattern delegates to _get
- tests: real-unit sandbox run, both-shapes catalog pin, nested-chain regression

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ValueError is wrapped opaquely by the SDK's template handler; ResourceError
passes through (mirror of the tools' ToolError). Adds client-boundary tests
asserting the hint text, and routes prompt lookups through _get.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@SuperElectron
SuperElectron merged commit 35b44ef into staging Aug 27, 2026
3 checks passed
@SuperElectron
SuperElectron deleted the feat/v2-pilot-chain-of-responsibility branch August 27, 2026 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant