docs(architecture): show the public surface, and pin it - #375
Merged
Conversation
Hard rule 5 says the public interface is a declared model rather than a Python API. Nothing said what that was worth in names, and nothing stopped it growing. - PUBLIC_API in tests/test_architecture.py pins the surface by role, checked in both directions: __all__ must match the table, and no public non-module attribute may exist outside it. The second half caught PackageNotFoundError, an stdlib exception sitting in lpspec's namespace since the version shim was written — now imported privately, like the version helper beside it. - A second test holds the linopy shim to its two verbs; a third would mean it had started being a lane of its own. - ARCHITECTURE.md gains "The Python surface": sixteen names in four groups, plus the shim and the Result methods. Hard rule 5 links to it. - The consumers diagram carries the names, one per box, so solid-vs-dashed reads as "has a name today" rather than needing the caption to say so. Co-Authored-By: Claude Opus 5 (1M context) <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.
Follow-up to #373. Hard rule 5 says "the public interface is a declared model, not a Python API" — but nothing said what that was worth in names, and nothing stopped it growing. Narrow is a feature; it should be countable, visible, and enforced like every other fence in this file.
Pinned
PUBLIC_APIintests/test_architecture.py, checked in both directions:__all__must match the table — catches a name documented and never exported, or exported and never documented.__init__.py.Either alone rots. The second half found one on its first run:
lpspec.PackageNotFoundError, an stdlib exception public in the package namespace since the version shim was written. It is now_PackageNotFoundError, matching the_installed_versionalias directly beside it.A second test holds the linopy shim to its two verbs —
buildmakes a model,extendadds to one. A third would mean the shim had started being a lane of its own, which hard rule 3 spends its length refusing.Shown
New "The Python surface" section: the whole surface as one table, grouped the way the diagram is — load it · show it · check it · run it · read it · catch it — with a "you want to" column so a name is reachable from the question that leads to it. Hard rule 5 links to it.
Italic rows are the entries the shape makes cheap and nobody has built (watch what a build is doing, will that solver take it, re-solve with new numbers). They are in the same table as the rest, because the claim being made is precisely that they are not a rewrite.
The consumers diagram
Rebuilt, and smaller than it was. It had three subgraphs of three unconnected nodes each, so
direction TBdid nothing and mermaid laid it out nine boxes wide — and its leaves duplicated the table directly below it.A diagram should carry what is actually shaped: the narrow waist and the fan-out. A list of twelve capabilities is not shaped, it is a list. So it is now five boxes on one line —
— and the twelve leaves are rows in the table. "Ships today vs. cheap to build" was a line style the caption had to explain; it is now an italic row.
Both diagrams re-rendered through
mermaid-clito confirm, since multi-line labels in stadium nodes overflow their rounded caps.Verification
709 passed / 4 skipped / 1 xfailed ·
ruff checkclean ·pyrefly0 errors ·mkdocs build --strictclean.The only source change in the PR is the private alias for
PackageNotFoundError. Removing a name from a package namespace is technically breaking, but it was never exported, never documented, and isimportlib.metadata's own class — anyone who wanted it was importing it from the stdlib.Not done
docs/index.mdhas six landing-page feature cards and none is about the API surface. A seventh — "sixteen names" — is probably the strongest version of this point for a first-time reader, but that page is the pitch, so it is your call rather than mine.typeset/renders as a small box wedged between the two big lanes, which understates it. Left alone here rather than churned in a docs PR.🤖 Generated with Claude Code