UmweltDocs
Reference/Queries/context.admit
context.admitquerysince 0.1

Decides which records and events may enter a context for a perspective, within a budget, with a reason for every refusal.

Request
umwelt call story.umw context.admit '{
  "projectId": "ball",
  "holder": "ana",
  "at": { "tick": 3 },
  "budget": 3,
  "candidates": [
    { "id": "c1", "recordId": "ana-saw", "cost": 2, "priority": 2 },
    { "id": "c2", "eventId": "scene-1", "cost": 1, "priority": 1 },
    { "id": "c3", "recordId": "theft" },
    { "id": "c4", "recordId": "bob-hid" }
  ]
}'
Request
const result = await client.contextAdmit({
  projectId: 'ball',
  holder: 'ana',
  at: { tick: 3 },
  budget: 3,
  candidates: [
    { id: 'c1', recordId: 'ana-saw', cost: 2, priority: 2 },
    { id: 'c2', eventId: 'scene-1', cost: 1, priority: 1 },
    { id: 'c3', recordId: 'theft' },
    { id: 'c4', recordId: 'bob-hid' },
  ],
});
Request
var result = engine.ContextAdmit(new ContextAdmitInput
{
    ProjectId = "ball",
    Holder = "ana",
    At = new At { Tick = 3 },
    Budget = 3,
    Candidates = new()
    {
        new ContextCandidate
        {
            Id = "c1",
            RecordId = "ana-saw",
            Cost = 2,
            Priority = 2,
        },
        new ContextCandidate
        {
            Id = "c2",
            EventId = "scene-1",
            Cost = 1,
            Priority = 1,
        },
        new ContextCandidate { Id = "c3", RecordId = "theft" },
        new ContextCandidate { Id = "c4", RecordId = "bob-hid" },
    },
});
Response
{
  "admitted": [
    { "id": "c1", "recordId": "ana-saw", "cost": 2, "priority": 2 },
    { "id": "c2", "eventId": "scene-1", "cost": 1, "priority": 1 }
  ],
  "rejected": [
    { "id": "c3", "recordId": "theft", "reason": "not-held" },
    { "id": "c4", "recordId": "bob-hid", "reason": "not-held" }
  ],
  "usedBudget": 3
}

Payload

FieldTypeDescription
projectIdrequiredstringThe project to read.
holderstringWhose perspective. Absent: the narrator’s, who sees everything visible at the position.
budgetintegerThe total cost allowed. Absent: no limit.
candidatesrequiredContextCandidate[]What you would like to include: your own id, exactly one of recordId and eventId, a cost (default 1), a priority (default 0) and an optional classification.
authorizedNarratorbooleandefault falseConfirms the caller may see withheld knowledge.
excludeClassificationsstring[]default []Classifications to refuse, such as spoiler.
includeWithheldbooleandefault falseAdmit suppressed and inaccessible Holdings. Requires authorizedNarrator.
atAtdefault {}Where to read: tick, an optional axis, and asOfVersion. Defaults to the latest.
timelineIdstringdefault "main"The timeline to read.

Result

FieldTypeDescription
admittedalwaysContextAdmitted[]Admitted candidates, highest priority first (ties keep input order).
rejectedalwaysContextRejected[]Refused candidates, in input order, each with its reason.
usedBudgetalwaysintegerThe cost of what was admitted.

Rules

Checks run in order. A refused candidate reports the first one it fails: invalid-candidate, not-in-project, future, not-on-axis, inactive, not-held, withheld, excluded-classification, duplicate, over-budget.

Being present grants nothing. An event is admitted for a holder only when they hold a Holding witnessed there. Facts are never in a holder’s perspective.

The budget is filled by priority. Survivors are taken by priority while they fit; a smaller candidate later in the list may still fit.

Errors

VALIDATION_FAILEDThe payload is malformed, or includeWithheld is asked without authorizedNarrator.
NOT_FOUNDThe project, holder or timeline does not exist, or the draft read was purged.
INVALID_STATEThe timeline read is a draft that was promoted. details.promotedInto names the timeline to read instead.
HANDSHAKE_REQUIREDOver the protocol, hello was not sent first.

Every code is listed in Errors.

See also

Was this page helpful?