Python data-dict.yaml reader and the three prompt channels - #253
Merged
Conversation
The input is the authored YAML, never data-dict's JSON export, so what is validated is the published data-dict spec. Parsing is permissive about fields commons never inspects and strict about the shape it does: a number(quantity) column with no range reads without complaint, because nothing reads that range. Prose stays as authored markdown, since it reaches the model verbatim. The three channels are methods on the dictionary. pkg-r spreads the same rendering across data-dictionary.R, prompt.R and context-layer.R; here the dictionary owns it and the prompt and context layers will call in. That is a difference in shape, not in what either produces. Glossary entries are ambient up to a size cap, and those past it are co-resolved at first touch when an entry mentions them, so capping loses nothing. Column-level content stays out of the search index: first touch owns it, and indexing it would pay for a second copy the agent has. `dictionary` applies to every source form, so unlike `tables` it is always an option rather than a possible frame name. Passing a frame there fails by name rather than being silently dropped.
They render as compiled SQL rather than the authored expression, so there is nothing correct to show until the compiler can supply records.
jat255
marked this pull request as draft
September 2, 2026 00:45
jat255
force-pushed
the
jat255/m2-data-dictionary
branch
from
September 2, 2026 00:45
e4fa2c0 to
bf66272
Compare
Both names are now reserved by the signature itself rather than by hand in **kwargs handling, matching the signature the port plan sketched. A frame passed under either name fails with a TypeError naming it; frames genuinely named 'tables' remain available via DataSource.from_frames().
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.
Third PR of M2. Reads the authored
data-dict.yamlinto pydantic models and renders the three channels a dictionary feeds. Closes the dictionary issue for M2.What it reads
The input is the authored YAML, never data-dict's JSON export, so what is validated is the published data-dict spec. Parsing is permissive about fields commons never inspects and strict about the shape it does: a
number(quantity)column with norangereads without complaint, because nothing reads that range. Tables and columns may be authored as sequences with anamefield or as a pre-keyed mapping, and both key the same way.Prose stays as authored markdown, because it reaches the model verbatim.
The three channels
They are methods on the dictionary rather than separate structures:
ambient_prompt_text()andambient_glossary_terms(),entry_text(table)for first touch, andcontext_chunks()for the search index.pkg-rspreads the same rendering acrossR/data-dictionary.R,R/prompt.RandR/context-layer.R. Putting it on the dictionary means the prompt and context layers call in rather than reaching into its internals. That is a difference in shape, not in what either produces.Glossary entries are ambient up to a size cap, and entries past it are co-resolved at first touch when an entry mentions them, so capping loses nothing. Column-level content deliberately stays out of the search index: first touch owns it, and indexing it would pay for a second copy the agent already has.
Known gap: Governed definitions are parsed but not yet rendered
definitionsin a data-dict are parsed into the model, and neither channel renders them yet.This is a known gap at this point and is staged to be implemented in a later task on M2. First touch shows a definition's compiled SQL, never the expression authored in the data-dict file, which
pkg-r's own test asserts by checking the expression is absent from the entry. Nothing correct can be shown until the compiler produces export records, so both channels will be wired in at that point. Comments mark both seams.For the same reason
expris optional on the model.pkg-rvalidates it in the export spec, not in the reader, and aborts the whole read when it fails. Checking it in both places would be two spellings of one rule to keep in step.Two reserved keywords
tablesanddictionaryare explicit keyword-only parameters, so both names are reserved in every form ofdata_source(). A frame passed under either name is rejected with a TypeError naming it, never silently consumed. Frames genuinely namedtablesremain available viaDataSource.from_frames().Verification
274 tests, ruff and pyrefly clean.