On this page

Context resolution

The DemandDrivenContextProjector turns validated requirement paths into the minimal render context for one file. It resolves directly from IR and planning indexes. There's no expanded context-IR copy (decision 0005).

The vocabulary itself (every context type and field) is in context.

Envelope

RootSourceWhen available
filethe PlannedFileArtifactalways
applicationthe active application (bounded metadata)always; resolved only when requested
pack.inputs.<key>usage inputs checked against the pack declarationalways
subjectIR, by subject + scopeeach → schema, property.enum… · all / collects.* → schemas[], properties.enums[]…
groupthe partition identitycollects.group, and collects.feature (owner)
featurethe partition identitycollects.feature

The collector always comes from the partition, never from the first item.

Algorithm

For every requirement:

  1. take the root from the envelope;
  2. walk only the requested segments, projecting while traversing (never materialise and then prune);
  3. resolve $refs only when traversal reaches them, delegating to the authoritative resolver for that context type;
  4. compute name variants and derived values only when requested;
  5. take file facts only from planning;
  6. apply absence rules, memoise safe lookups, and merge the result into one output tree;
  7. discard the per-file context after rendering.

Requirements are merged into one request tree. A parent path never implies its children unless it's a subtree request.

Absence

CaseResult
Not requestedkey omitted
Requested, optional object or scalar absentnull
Requested, collection empty[]
Requested inactive variant branch (e.g. value.property when value.kind = schema)null

Ordering

Each collection uses the order its contract defines: tuple and ordered-enum order, canonical order for unordered enums, effective schema field order, planning order for file.dependencies, and export-stream order for file.exports. Dictionary iteration order is never used.

Bounds and cycles

Subtree expansion stops at context-reference boundaries. Semantic cycles (User.manager → User) are safe because request paths are finite. A guard keyed on context type + canonical identity + request node turns any recursive attempt into a bounded diagnostic.

Errors

CodeMeaning
context.request.invalidThe path isn't in the vocabulary
context.root.unavailableValid path, but not available for this invocation
context.reference.invalidBroken or incompatible canonical reference
context.resolution.boundedA forbidden recursive expansion was attempted
context.projection.planned_artifact_missingExpected generated representation not planned. Names the consumer, target and allowed producers

Projection-specific failures use the context.projection.* family, e.g. root_invalid, pack_input_undeclared, application_ambiguous, port_missing.

Evidence

project_with_evidence() returns the context plus the requested, materialised and unmaterialised paths, and typed provider provenance (no values). This feeds tracing.

Search in