Skip to content

Traits

A trait is a named micro-capability: a partial schema contributing zero or more attributes to the entity that declares it. Composition is commutative and associative; the trait vocabulary is closed and canonical, and a name is never renamed or aliased.

Traits marked (marker) contribute no attributes: they declare a capability whose data lives in edges, which are stored once, outgoing direction only.

Base

TraitAttributes contributedNotes
TNamedname: stringNot universal: lambdas, closures, Rust impl blocks, Java constructors have no own name
TSourceAnchoranchor: SourceAnchorEvidence for the entity’s declaration
TCommentcomments: string[]Attached documentation/comments

Containment and attachment

Where an entity is written (lexical containment) and what it semantically belongs to (attachment) are different relations, and both are kept.

TraitAttributes contributedRelation expressed
TWithChildrenchildren: EntityId[] (v1 only, see below)lexical containment, downward
TChildOfparent: EntityIdlexical containment, upward — the STORED direction
TAttachedToattachedTo: EntityIdsemantic attachment. Required by: Go receiver methods, Rust impl blocks, C# extension methods, Clojure extend-type/defmethod

A Go method with receiver (o *Order) is a child of its file/package and attached to Order.

children is an inverse index, not a fact. It is the exact inverse of parent, and inverse views are derived in memory, never serialized. TWithChildren stays a declared trait: it says an entity is a container. Only the serialized key goes.

Modularity

TraitAttributes contributedNotes
TModuledefinedIn: string[] (CodeFile paths), isStub: booleanmodule↔file cardinality varies by language: 1-1 (JS/TS/Python: module is the file), 1-N (Java package, C#/Go/PHP namespace), N-N (Rust inline mod). A stub module has definedIn: [], which is exactly what makes it external

Types

TraitAttributes contributedNotes
TTypeisStub: booleanany type-like entity: class, interface, struct, enum, protocol, PHP/Rust trait
TWithInheritances(marker) — see inheritance edgesmultiple inheritance = N edges (Python). Absent from the Go and Rust profiles — that absence is profile information, not a gap
TWithImplements(marker) — see interfaceImplementation edges
TTypedEntitydeclaredType?: EntityIdoptional even when the trait is present: absent value in JS/Python/Clojure, C# var, inferred Go/TS/Rust

Behavior

TraitAttributes contributedNotes
TInvocablesignature: stringsignature is part of identity (Java/C# overloads, Go receivers)
TWithParametersparameters: EntityId[]ordered
TWithLocalVariableslocalVariables: EntityId[]
TWithInvocations(marker) — see invocation edgesoutgoing only; incoming is derived by the analyzer, never stored

Structure

TraitAttributes contributedNotes
TStructural(marker) — value holderattributes, variables, parameters, Clojure vars. Legal target of access edges
TWithAccesses(marker) — see access edgesoutgoing only
TWithValuevalue: Literalthe entity’s declaration-site constant value. Optional wherever licensed — absence means “not constant”, never “empty”

Measures

TraitAttributes contributedNotes
TMetricsmetrics: Record<string, number>open map of measured finite numbers. Only the extractor writes it

See Measures and literals.

The composition that motivates the design

A Clojure var holding a function is simultaneously named, a value holder, and invocable: traits: [TNamed, TStructural, TInvocable]. No tree-shaped hierarchy can place it; trait composition expresses it directly. The argument is in Why traits.

The closed vocabulary

Nineteen names, in the order the header dictionary’s enum declares them:

TNamed · TSourceAnchor · TComment · TWithChildren · TChildOf · TAttachedTo · TModule · TType · TWithInheritances · TWithImplements · TTypedEntity · TInvocable · TWithParameters · TWithLocalVariables · TWithInvocations · TStructural · TWithAccesses · TMetrics · TWithValue

The keys each contributes on the wire are listed under model.jsonl.

Last updated on