Uh oh!
There was an error while loading. Please reload this page.
feat(models): cpg — canonical schema-v2 models, modeled once (F2 / #240) - #274
Merged
Conversation
span is listed as a common field on every node in the keystone (Part II), module included, but Module had no span field so it degraded to a raw dict in model_extra instead of parsing as Span. The ts-a4/ts-a1 fixtures emit span on the module node.
…ct (#240) extra="allow" absorbs unknown keys, so deleting a canonical field leaves every parse test green — the accessor contract is the only guard. cdg and summary (both in F7's cfg/cdg/ddg/summary read set), the envelope k_limit, and TS callable body/cfg were unpinned. Each new assertion dereferences an element/field rather than doing a bare isinstance check, since a raw dict-of-dicts under extra="allow" still satisfies isinstance(list)/isinstance(dict) — confirmed by temporarily removing each field from the model and watching the new asserts fail before restoring.
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 freeto 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.
cpg models — canonical schema-v2, modeled once (F2 / #240)
Closes #240. Adds
cldk/models/cpg/— Layer 1 of the two-layer model: the schema-v2 Pydantic models, modeled ONCE, that parse theanalysis.jsonof every CLDK analyzer. Part of epic #238 (2.0.0-rc.1). Unblocks F7 Tasks 7–10 (#270) and F3 views (#241), which read these models directly.What's here
base.py—_NullSafeBase:extra="allow"(one model set tolerates every language's extras — the opposite of the old per-languageextra="forbid") + a null-drop validator (coercesnullcollections to defaults for Go/Rust/C).models.py—Span(byte offsets),Edge({src,dst,kind?,var?,prov,weight}— the list-name is the type, noCALL_DEPfield),Import, open-kindNode(one model over type/callable/field/body facets, self-referential,kind:str),Module(+source,+span),Application,Analyzer,AnalysisPayload(envelope;max_levelauthoritative).types/functions/callables/fields) require anid; body nodes (keyed by local position inbody{}) may omit it — via container validators, not a kind-list (respects open-kind).Validation — the point of the layer
30 tests. Parses REAL, conformant
--eageroutput from BOTH analyzers (codeanalyzer-python + cants/TypeScript) at L1 and L4 (4 committed golden fixtures), holds theL1 ⊆ L4superset gate, and pins the exact accessor surface F7's Task-7 provider and F3's views consume — with discriminating guards (underextra="allow", a naiveisinstancecan't detect a removed field, so the accessor tests dereference past the container and checkmodel_extramembership).Scope / safety
Purely additive — a new package, no imports into any existing facade; the frozen per-language models/facades are untouched.
Built via subagent-driven TDD with two-stage review; the gate caught 8 defects the passing tests didn't reveal
Including a too-broad
Node.idrelaxation that silently voided the keystone join-key invariant for durable nodes, a short-circuited accessor assertion giving false coverage, and (whole-branch)Module.spandegrading to a raw extra +extra="allow"making parse-tests non-probative for field presence.Known follow-ups (do NOT block this merge — filed)
base_classes≠base_types,attributes≠fields,cyclomatic_complexity≠metrics.cyclomatic), so those canonical fields parse EMPTY on real data. Analyzer-side conformance / keystone reconciliation — must be resolved before F3 maps those fields. #273 also folds in the nested-types question (keystone uses flattype.nesting, not aNode.typescontainer).file_pathextras, pretty-print, makepy-a1a pure L1 exemplar; switchnext(iter(...))selectors to named keys.