Global Bean Lookup
Use this page when AI or contributors need to identify which backend shorthand a bean name refers to, or decide where to continue searching after a shorthand lookup fails.
Why this lookup rule matters
Backend work often starts from code such as:
this.bean.databasectx.bean.modelapp.bean.xxx
If an agent treats every bean-like class as part of one flat container, it wastes time and often inspects the wrong scene first.
The goal of this rule is to make global bean lookup fast and structurally correct:
- use
IBeanRecordGlobalfor global shorthand lookup - use
IBeanRecordGeneralfor general full-name lookup - use service-scene metadata and
src/servicefor runtime-anchor and service lookup - use class placement, not metadata exceptions, to keep these surfaces clean
The three lookup surfaces
1. IBeanRecordGlobal
Use IBeanRecordGlobal for the global shorthand authoring surface.
This is the first static lookup surface when backend code references:
this.bean.xxxctx.bean.xxxapp.bean.xxx
Typical source of truth:
- module
src/.metadata/index.ts - corresponding
src/beansource file
Examples:
databasemodel
2. IBeanRecordGeneral
Use IBeanRecordGeneral for the general full-name bean surface.
This is the right lookup surface when code references a bean by full name, such as:
bean._getBean('a-orm.service.database')- generated general bean registrations
- scene-qualified bean identities that are not global shorthand
Do not use IBeanRecordGeneral as the first lookup step for shorthand expressions like this.bean.xxx.
3. Service-scene and runtime-anchor lookup
Use src/service, service metadata, and class-token/selector call sites for classes that are not global shorthand but still rely on container-managed behavior.
This is the right path for:
- runtime-anchor bases
- selector-based services
- class-token lookup targets
src/service/*_.tsclasses that should not participate inIBeanRecordGeneral
Examples:
databaseDialectBase_.ts- cache/summer runtime-anchor bases in
src/service
The default lookup workflow
When backend code references this.bean.xxx, ctx.bean.xxx, or app.bean.xxx, prefer this sequence:
- check
IBeanRecordGlobalin the relevant modulesrc/.metadata/index.ts - map the shorthand name to the generated bean type
- jump from the generated type to the source file in
src/bean - inspect neighboring bean-scene shorthand files only if needed for context
- only if the shorthand is not found, re-evaluate whether the target is actually:
- a general full-name bean
- a service-scene runtime-anchor
- a lib/helper class
This keeps shorthand lookup fast and avoids jumping into src/service or src/lib too early.
What to do when the shorthand is not found
If IBeanRecordGlobal does not contain the target name, do not assume the metadata is incomplete.
Re-check the problem category:
- Is the code actually using a full-name bean?
- then inspect
IBeanRecordGeneral
- then inspect
- Is the target really a service-scene runtime-anchor or selector target?
- then inspect
src/service, service metadata, and selector/class-token call sites
- then inspect
- Is the target only a helper or superclass chain?
- then inspect
src/lib
- then inspect
The absence of a name from IBeanRecordGlobal often means the target is not a global shorthand at all.
Relationship to class placement
This lookup rule depends on correct backend class placement.
src/beandefines the global shorthand surface- classes that should not be global shorthand belong in
src/liborsrc/service @Virtual()does not remove a bean-scene class fromIBeanRecordGlobal
That means lookup quality is improved structurally by placing classes correctly, not by adding more metadata exceptions.
For placement decisions, also read Class Placement Rule.
Practical examples
Example: this.bean.database
- inspect the owning module
src/.metadata/index.ts - find
databaseinIBeanRecordGlobal - map it to the generated bean type
- jump to the corresponding
src/beansource file
Example: ctx.bean.model
- inspect
IBeanRecordGlobal - find
model - jump to the bean-scene shorthand in
src/bean/bean.model.ts - continue into
src/libonly if deeper superclass logic is needed
Example: database dialect runtime anchor
If the target is a dialect base or class-token runtime anchor and does not appear in IBeanRecordGlobal, that is expected.
Continue with:
src/service- service metadata
- class-token or selector call sites
Anti-patterns to avoid
Avoid these mistakes:
- treating
IBeanRecordGlobalas a full container inventory - jumping to
src/servicefirst when the code clearly usesthis.bean.xxx - assuming a missing shorthand means metadata is broken before checking whether the target is actually global
- keeping non-global classes in
src/beanand compensating with metadata patches - using
@Virtual()as a shorthand-registration filter
Related guidance
Read these pages together: