Skip to content

feat(styling): compile_display_source + check_styling, a strict way to vet display klasses - #985

Open
paddymul wants to merge 3 commits into
mainfrom
feat/983-strict-display-check
Open

paddymul wants to merge 3 commits into
mainfrom
feat/983-strict-display-check

Conversation

@paddymul

Copy link
Copy Markdown
Collaborator

Closes #983.

A host that registers project display klasses has no way to find out whether a class works short of rendering a table, and rendering doesn't say either. style_column_with_fallback catches the exception, logs it and falls back to the parent class. A class that calls getattr, which isn't in the sandbox builtins, loads fine and then loses its styling on every column. Loading has the same gap: load_project_display_klasses logs and skips a file that fails to exec, and the only path that raises takes a file path.

This adds three things.

compile_display_source(source, name) in server/xorq_loading.py runs source text through the display loader's sandbox (same builtins, same injected base classes) and raises where the loader would skip. The loader and this function now share _exec_display_source. name stands in for the file stem and has to be an identifier, since the loader would skip it otherwise. _compile_project_display(path, ...) keeps its signature, because tallyman's prototype calls it.

check_styling(klass, sd, df) in dataflow/styling_core.py tries each column that style_columns would style and returns a StylingFailure(col, orig_col_name, klass, exc) for each one that fails. It doesn't stop at the first failure and doesn't modify the sd. It shares the MRO walk (_style_column_chain) and the column enumeration (_columns_to_style) with the render path, so both paths agree on which columns get styled and in what order.

A failure means the most specific style_column raised or returned something that isn't a column config, even when a parent's would have worked. The point is to catch a class that silently loses its own styling, and that's the case where the fallback hides it. klass on the failure is the class that defines the style_column that raised, which is a parent when the checked class inherits style_column. A class that doesn't override style_column at all is checked against its default_styling, since that's what rendering reaches first. Passing something that isn't a StylingAnalysis subclass raises TypeError.

SAFE_BUILTIN_NAMES is the builtins list under a public name, for hosts to quote in error messages. Nothing in the repo used the underscored name, so there's no alias.

Rendering is unchanged: a failing class still falls back to its parent.

The first commit adds the failing tests; the fix follows once CI has shown them failing.

🤖 Generated with Claude Code

paddymul and others added 2 commits September 30, 2026 16:09
…ling (#983)

A display klass that calls getattr (not in the sandbox builtins) compiles and
loads fine, then raises on every column once styled. Rendering falls back to
DefaultMainStyling and logs, so nothing tells the host the class is broken.

check_styling(klass, sd, df) should report each column whose most specific
style_column raises or returns a non-config, with the column, orig_col_name,
the class and the exception, and leave the sd alone. compile_display_source
should run source text through the display loader's sandbox and raise where the
loader would log and skip. SAFE_BUILTIN_NAMES gives hosts the builtins list for
error messages.

The new tests reach these names through the module, so each one fails on its
own instead of taking down the files' existing tests at collection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…errides default_styling (#983)

With no style_column override, rendering goes straight to default_styling, so
that's what check_styling has to try first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

📦 TestPyPI package published

pip install --index-strategy unsafe-best-match --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ buckaroo==0.15.8.dev36771686771

or with uv:

uv pip install --index-strategy unsafe-best-match --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ buckaroo==0.15.8.dev36771686771

MCP server for Claude Code

claude mcp add buckaroo-table -- uvx --from "buckaroo[mcp]==0.15.8.dev36771686771" --index-strategy unsafe-best-match --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ buckaroo-table

📖 Docs preview

🎨 Storybook preview

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 83cb2bc330

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".



def test_compile_display_source_returns_display_klasses():
klasses = xorq_loading.compile_display_source(MINIMAL_DISPLAY, "my_display")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add the APIs exercised by the new tests

compile_display_source is not defined in buckaroo.server.xorq_loading at this commit (nor are SAFE_BUILTIN_NAMES or styling_core.check_styling added anywhere), so this and the other newly added tests fail with AttributeError rather than validating the described feature. Implement the production APIs in the same change, or defer these tests until that implementation is included.

Useful? React with 👍 / 👎.

…o vet display klasses (#983)

compile_display_source(source, name) runs source text through the display
loader's sandbox and raises where load_project_display_klasses logs and skips.
Both go through _exec_display_source; _compile_project_display keeps its
signature for tallyman's prototype.

check_styling(klass, sd, df) tries every column style_columns would style and
returns a StylingFailure per column whose most specific style_column raises or
returns a non-config (default_styling when nothing overrides style_column). It
shares the MRO walk (_style_column_chain) and column enumeration
(_columns_to_style) with the render path, which is unchanged.

_SAFE_BUILTIN_NAMES becomes SAFE_BUILTIN_NAMES.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
testpypi — 7c31ffa0 Deployed Sep 30, 2026 by paddymul via Publish to TestPyPI #1592
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.

Expose a strict way to load and style a project display klass without rendering

1 participant