feat: v2 pilot — chain_of_responsibility as module + engine support - #17
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 0 of the patterns-as-modules refactor (plan of record:
.cache/plan.md, local).What
pattern/(genericChain[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. Oldnaive.py/pythonic.py/real_world.pydeleted.src/design_patterns_mcp→src/design_patterns/mcp(top-levelmcpcollides 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 toolsget_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 checkgreen: ruff, mypy --strict (211 files), 281 tests, readme table current. Real-unit smoke: example runs via module path and through the sandboxedrun_exampletool.🤖 Generated with Claude Code