feat: public description-prompt API and explicit generate_description behavior (0.0.6) - #75
Merged
Merged
Conversation
… behavior Two related gaps made it impossible for a caller to know whether a column description actually came from the LLM: - generate_description() returned early, without calling the model, for any column whose description came from a SQL comment (description_source is SOURCE) - returning the authored text unchanged. - It also caught LLM errors and substituted a rule-based description derived from the column name, setting description_source to GENERATED either way. A tool attributing the result to a model could therefore label a fallback string, or the user's own hand-written comment, as model-generated output. Adds, all backward-compatible: - build_description_prompt() as public API (the private _build_description_prompt name remains an alias), so callers can reuse clgraph's lineage-aware prompt and drive the model themselves. - generate_description(..., overwrite=False, on_error="fallback") keyword-only parameters, and a bool return that is True only when the LLM produced the stored description. - DescriptionGenerationError, raised when on_error="raise". - The same overwrite/on_error pass-through on Pipeline.generate_all_descriptions and MetadataManager.generate_all_descriptions. Also retitles the stale CHANGELOG [Unreleased] section as [0.0.5], which is what it shipped as, and bumps the version to 0.0.6.
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.
Summary
Two behaviors in
generate_description()made it impossible for a caller to know whether a column description actually came from the LLM:description_source == SOURCE) — returning the authored text unchanged.order_id→"Order Id"), settingdescription_source = GENERATEDeither way.A tool attributing the result to a model could therefore label a fallback string — or the user's own hand-written comment — as model-generated output. This was found in practice: clgraph Studio's describe endpoint was relabelling authored governance text as "AI-generated" for 57 of 94 columns in one demo pipeline.
What changed
Added
build_description_prompt(column, pipeline)promoted to public API and exported from the package root, so callers who want to drive the model themselves can reuse clgraph's lineage-aware prompt._build_description_promptremains as an alias.generate_description(..., overwrite=False, on_error="fallback")— keyword-only.overwrite=Truedescribes a column even when a SQL comment already documented it.on_error="raise"raises the newDescriptionGenerationErrorinstead of silently writing a fallback.generate_description()now returnsbool—Trueonly when the LLM produced the stored description.overwrite/on_errorpass-through onPipeline.generate_all_descriptions()andMetadataManager.generate_all_descriptions().Housekeeping
[Unreleased]section sat directly above[0.0.3]whilepyproject.tomlsaid0.0.5. That content was written 2026-07-20 and shipped in thev0.0.5tag (2026-07-31), so it is retitled[0.0.5] - 2026-07-31. New[0.0.6]section added.0.0.6.Compatibility
No breaking changes. All new parameters are keyword-only with defaults that preserve the previous behavior exactly, the new
boolreturn replacesNone(falsy either way), and the private prompt-builder name still resolves.Test plan
tests/test_description_generation_api.pycovering: public export and private alias,overwritein both directions,on_errorfor both LLM failure and output-validation rejection, theboolreturn, keyword-only enforcement, and that an invalidon_erroris rejected before the LLM is called.ruff check/ruff format --checkclean.tyreports 52 errors; the releasedv0.0.5tag reports the same 52, so this change adds none.clgraph-docsto be merged alongside.