MyJackfruit

Help
Browse topics · More from code, and code examples

More from code, and code examples

← More from code, and code examples

How do I run a standard in order from code?

Short answer

Read the standard's units, check that orderSemantics is sequence and runnable is served, then run the units by ordinal.

Before you start

The standard's id, the last part of its address, and its vault's host.

Words used here (5)
Procedure
A Procedure is the kind of standard that holds an agent: who you call, and the steps that agent runs, in order.
agent
An agent is your AI following one written procedure, its standing instructions, for one kind of work.
GilbPlatform
GilbPlatform is the service that keeps people's and organisations' data in vaults, each at its own web address.
field
A field is one named fact on a record, such as its title or a due date; its name comes from GilbVeda.
short name
A short name is the one word you give one AI on one computer, such as gilb-example; it keeps that AI's key and tools apart.
Steps
  1. Read the standard with its units.

    Fetch the standard and its units, with a token and a new proof if its vault is not public:
    GET https://<vault host>/lws/procedure/<id>/proceduresteps?limit=200

    More about this

    A unit is one point of a standard: a step, a rule, a question. Each other kind of standard has the same route, ending /lws/ruleset/<id>/rules, /lws/checklist/<id>/questions, /lws/policy/<id>/statements, /lws/template/<id>/specimens, /lws/lookup/<id>/entries or /lws/referencedocument/<id>/exhibits. A page holds 20 units unless you set limit, up to 200; complete false means there are more. Each unit comes back only if you may read it, and a standard you may not read answers 404.

  2. Check that orderSemantics is sequence.

    Walk the units as steps only when the answer's orderSemantics is sequence. With display-fidelity the numbers say only where each unit is shown, not an order to do them in.

    More about this

    A Procedure, the kind of standard that holds an agent, answers sequence, with orderSemanticsTerm t:Sequence. Rule sets, checklists, policies, templates, lookups and references answer display-fidelity, with t:Indicate. The steps of a Process come back without orderSemantics: a Process is run by moving one run of it on, as the answer on how processes and decisions run on GilbPlatform shows.

  3. Check that runnable is served.

    Run the units only when runnable.served is true. When it is false, runnable holds no units, and runnable.unserved names each unit whose address does not resolve.

    More about this

    An unresolved unit is one whose own address, GET /lws/r/<id>, does not answer with a body.

  4. Run the units in order of ordinal.

    Sort runnable.units by ordinal and do each one's payload.value, the text of that step, in that order.

    More about this

    payload.key names the field the text came from, such as a:procedureStep. id.value is the unit's own address; it can be read, but it is not kept when a standard is imported again. tag.value, when there is one, is the unit's tag, such as Agent.Coder.Role, the short name it is cited by. A step that hands off names another standard; the answer on following a hand-off shows what to do.

Deeper

Checked on production on 2026-11-11, with no token: the Procedure Agent.Coder at https://appbuilder.gilb.com/lws/procedure/06gf80g4e5xhzfm96gsrtbh8g4/proceduresteps answered orderSemantics sequence, runnable.served true and 15 units in order, from Agent.Coder.Role to Agent.Coder.HumanActs; a rule set in the same vault answered display-fidelity.

With an offset above 0, complete is never true, so read up to 200 units in one page; the reading of a longer standard is not covered here. GilbPlatform does not run the steps for you: your code or your agent does what each step says.

Source: GilbPlatform 498d29a0 (live at https://id.gilb.com/version, read 2026-11-11): src/lws/standard-family.ts:62-84 (ORDER_SEMANTICS sequence | display-fidelity | unitless; t:Sequence, t:Indicate; unitIdentity @id, dereferenceable-not-reimport-stable), :101-113 (the ordinal's meaning is orderSemantics; Procedure ordinal IS the sequence), :160-224 (RunnableUnit id, ordinal, payload, tag; served false: unserved leg unitIdentity framed id does not resolve, precondition GET /lws/r/<id> must return 200 with a body), :405-430 (the document answer: orderSemantics, orderSemanticsTerm, executionPayloadKey, runnable, complete, pageSize); src/lws/standard-family-page.ts:72 (max 200), :118 (default 20), :194 (complete only at offset 0); src/lws/procedures.ts:35, :40 (sequence); src/lws/rulesets.ts:62, :68, checklists.ts:62, :67, policies.ts:60, :65, templates.ts:90, :95, lookups.ts:29, :34, references.ts:34, :39 (display-fidelity); src/lws/process-steps.ts:67 (process steps, another module). Public reads, no token, 2026-11-11: https://appbuilder.gilb.com/lws/procedure/06gf80g4e5xhzfm96gsrtbh8g4/proceduresteps -> 200, orderSemantics sequence, t:Sequence, executionPayloadKey a:procedureStep, runnable served, 15 units The example (as plain JS) ran: 15 units Agent.Coder.Role ... Agent.Coder.HumanActs in order; ruleset 06gjdq7m01y1sc3qrfevnpy5rc -> the order is display-fidelity, not a sequence. Repo team notes §10.3 not linked. Row: Developer.RunStandardInOrder.

For developers

TypeScript

steps-in-order.ts

type Unit = {
  id: { carrier: "@id"; value: string };
  ordinal: number;
  payload: { key: string; value: unknown };
  tag?: { carrier: string; value: unknown };
};

// documentUrl: such as https://<vault host>/lws/procedure/<id>/proceduresteps
// headers: Authorization and a new DPoP proof, if the vault is not public.
export async function stepsInOrder(documentUrl: string, headers: Record<string, string> = {}): Promise<Unit[]> {
  const page = await (await fetch(`${documentUrl}?limit=200`, { headers })).json();
  if (page.orderSemantics !== "sequence") throw new Error(`the order is ${page.orderSemantics}, not a sequence`);
  if (!page.runnable?.served) throw new Error(`not served: ${JSON.stringify(page.runnable?.unserved)}`);
  if (!page.complete) throw new Error("more than 200 units: read the rest before you run any");
  return [...page.runnable.units].sort((a: Unit, b: Unit) => a.ordinal - b.ordinal);
}

Checked against GilbApp d529620.