Skip to content

milestone: complete pattern catalog (32 units) - #9

Merged
SuperElectron merged 8 commits into
mainfrom
staging
Aug 27, 2026
Merged

milestone: complete pattern catalog (32 units)#9
SuperElectron merged 8 commits into
mainfrom
staging

Conversation

@SuperElectron

Copy link
Copy Markdown
Owner

Staging → main milestone. Everything since the scaffold:

  • Toolchain: uv, ruff, mypy --strict, pytest+cov, CI matrix 3.11–3.13, MIT license
  • Agent config: CLAUDE.md / AGENTS.md / .claude commands + skills
  • 32 pattern units: 1 principle + 3 Python-native + all 23 GoF + 5 modern, each with frontmattered README, naive/pythonic/real_world variants, and behavioral tests (211 passing)
  • Catalog loader validating every unit's frontmatter in CI

🤖 Generated with Claude Code

SuperElectron and others added 8 commits August 26, 2026 16:48
- pyproject.toml: hatchling build, ruff (lint+format), mypy --strict,
  pytest with coverage; legacy flat dirs excluded until catalog migration
- Makefile: install / lint / format / typecheck / test / check
- GitHub Actions CI on 3.11/3.12/3.13 (push to main/staging + PRs)
- MIT LICENSE, real .gitignore (incl. .omc/), docs/ skeleton
- src/design_patterns package stub + smoke test

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
- CLAUDE.md / AGENTS.md: repo layout, pattern-unit template, frontmatter
  schema, verdict vocabulary, branch/gate workflow, prose style
- .claude/settings.json: allow the make/uv quality-gate commands
- .claude/commands/new-pattern.md: /new-pattern unit scaffolder
- .claude/skills/pattern-authoring: variant roles, verdict rubric, test bar

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Nine complete units under patterns/<group>/<slug>/, each with
frontmattered README, naive.py (GoF translation), pythonic.py,
real_world.py (stdlib sighting), and behavioral tests:

- creational: builder, prototype, singleton
- structural: composite, decorator, flyweight
- behavioral: command, iterator, strategy

Legacy flat dirs removed (primary file per unit git mv'd for
history). Fixes carried by construction: strategy bulk_item
returned inside its loop; singleton __new__ passed args to
object.__new__; builder demo printed empty attributes.

Gates: ruff, mypy --strict (59 files), pytest (61 tests), all
27 demos run clean.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
src/design_patterns/catalog.py parses and validates every
patterns/<group>/<slug>/README.md frontmatter block into frozen
Pattern dataclasses: schema keys, verdict vocabulary, id/directory
agreement, https guide_url, and at least one shipped example are
all enforced with loud CatalogError messages. Catalog.to_json()
emits the future catalog://index payload.

Adds pyyaml (runtime) and types-pyyaml (dev). 14 new tests cover
the real catalog round-trip and every validation failure mode.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
New groups patterns/python/ and patterns/principle/, six new units:

- creational/abstract_factory — callables as factories; json parse_float
- creational/factory_method — DI, class/instance attribute factories;
  HTTPConnection.response_class
- python/global_object — constants, import-time rules, lazy init;
  math.pi, calendar.day_name, os.environ
- python/prebound_method — bound methods as module API; random.random
- python/sentinel_object — object() sentinels, Null Object;
  dataclasses.MISSING, iter(callable, sentinel)
- principle/composition_over_inheritance — subclass explosion vs
  composed axes; the logging module

Catalog at 15 units. 115 tests pass; ruff/mypy --strict clean; all
45 demo scripts run.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
- structural/adapter (pythonic) — function/__getattr__ adapters; io.TextIOWrapper
- structural/bridge (prefer-alternative) — composition + DI is the bridge; logging Logger/Handler
- structural/facade (pythonic) — module functions as facades; shutil.make_archive
- structural/proxy (use-with-care) — LazyProxy, cached_property; weakref.proxy

Catalog at 19 units; GoF structural complete. 134 tests, all 57
demos run, ruff/mypy --strict clean.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
- chain_of_responsibility (prefer-alternative) — list+loop; logging propagation
- interpreter (prefer-alternative) — tuple trees; safe ast evaluator; re
- mediator (use-with-care) — coordinator w/ callables; queue.Queue
- memento (use-with-care) — frozen-state snapshots; pickle round-trip
- observer (pythonic) — callables + property setter; Future.add_done_callback
- state (use-with-care) — Enum transition table + generator machines
- template_method (prefer-alternative) — steps as kwargs; JSONEncoder.default
- visitor (prefer-alternative) — singledispatch; ast.NodeVisitor

Catalog at 27 units: all 23 GoF patterns now covered. 180 tests,
81 demos run, ruff/mypy --strict clean.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
New group patterns/modern/:

- dependency_injection (pythonic) — Protocol seams, kwarg defaults;
  sorted(key=), json.dumps(cls=)
- repository (use-with-care) — Protocol + in-memory fake + sqlite impl
- context_manager (pythonic) — __enter__/__exit__, @contextmanager,
  ExitStack
- registry (pythonic) — decorator-filled dispatch dict; codecs
- async_producer_consumer (use-with-care) — asyncio.Queue + TaskGroup
  with backpressure and tested shutdown; thread version for contrast

Adds pytest-asyncio (auto mode). 211 tests; ruff/mypy --strict clean;
all 96 demos run as modules.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@SuperElectron
SuperElectron merged commit 3b22e3a into main Aug 27, 2026
6 checks passed
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