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.
The diagram is a map of this page: an entity composes at most one of each trait, so zero to all of a family’s. A dashed box is a marker, and the three red dots are the composition that motivates the design.
Base
| Trait | Attributes contributed | Notes |
|---|---|---|
TNamed | name: string | Not universal: lambdas, closures, Rust impl blocks, Java constructors have no own name |
TSourceAnchor | anchor: SourceAnchor | Evidence for the entity’s declaration |
TComment | comments: 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.
| Trait | Attributes contributed | Relation expressed |
|---|---|---|
TWithChildren | children: EntityId[] (v1 only, see below) | lexical containment, downward |
TChildOf | parent: EntityId | lexical containment, upward — the STORED direction |
TAttachedTo | attachedTo: EntityId | semantic 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
| Trait | Attributes contributed | Notes |
|---|---|---|
TModule | definedIn: string[] (CodeFile paths), isStub: boolean | module↔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
| Trait | Attributes contributed | Notes |
|---|---|---|
TType | isStub: boolean | any type-like entity: class, interface, struct, enum, protocol, PHP/Rust trait |
TWithInheritances | (marker) — see inheritance edges | multiple inheritance = N edges (Python). Absent from the Go and Rust profiles — that absence is profile information, not a gap |
TWithImplements | (marker) — see interfaceImplementation edges | |
TTypedEntity | declaredType?: EntityId, typeExpr?: TypeExpr | both optional even when the trait is present: absent value in JS/Python/Clojure, C# var, inferred Go/TS/Rust. declaredType is the erased head; typeExpr (contract 1.2.0) the type as written — see Type expressions |
Type expressions
typeExpr is the type a declaration writes, as a tree: List<OrderLine> is a named type with one argument, int[] an array of a primitive, T? a nullable. Eight forms, a closed vocabulary:
| Form | Shape | Notes |
|---|---|---|
named | {k: "named", type: EntityId, args?: TypeExpr[]} | a declared type or a stub, with its written type arguments in order; args absent when none is written |
primitive | {k: "primitive", name: string} | the language’s own word: int, long, boolean |
array | {k: "array", of: TypeExpr} | |
nullable | {k: "nullable", of: TypeExpr} | only where the language writes it (T?, T | null) |
function | {k: "function", params: TypeExpr[], returns?: TypeExpr} | returns absent = no value |
union | {k: "union", of: TypeExpr[]} | at least two, in written order |
variable | {k: "variable", name: string} | a type parameter |
unevaluated | {k: "unevaluated", source: string} | a written type the extractor did not structure (a wildcard); the text is still a fact |
It is what is written, never what is inferred: no typeExpr on a var or a void return. The ids inside count for closure, exactly like an edge’s ends, and the reference edges a written type emits are still emitted. No extractor writes it yet; the Java extractor is next.
Behavior
| Trait | Attributes contributed | Notes |
|---|---|---|
TInvocable | signature: string | signature is part of identity (Java/C# overloads, Go receivers) |
TWithParameters | parameters: EntityId[] | ordered |
TWithLocalVariables | localVariables: EntityId[] | |
TWithInvocations | (marker) — see invocation edges | outgoing only; incoming is derived by the analyzer, never stored |
Structure
| Trait | Attributes contributed | Notes |
|---|---|---|
TStructural | (marker) — value holder | attributes, variables, parameters, Clojure vars. Legal target of access edges |
TWithAccesses | (marker) — see access edges | outgoing only |
TWithValue | value: Literal | the entity’s declaration-site constant value. Optional wherever licensed — absence means “not constant”, never “empty” |
TWithReceiver | (marker) | evaluated against an instance of the type it is written in or attached to: an instance field, an instance method, a constructor (contract 1.2.0) |
TWithReceiver tells Order.channel from Order.MAX_LINES, which Java’s attribute kind does not. A profile licenses it, optional, on the kinds it can decide it for — Java: attribute, method, constructor. Where it is licensed, absence means “no receiver” (a static member, an enum constant); where it is not, absence means nothing. An access edge’s receiver is its counterpart on the edge.
Measures
| Trait | Attributes contributed | Notes |
|---|---|---|
TMetrics | metrics: Record<string, number> | open map of measured finite numbers. Only a source reader writes it: the extractor, or the metrics pass over its model |
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
Twenty 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 · TWithReceiver · TMetrics · TWithValue
The keys each contributes on the wire are listed under model.jsonl.