AgenticOS: ArcQL Query Language – Token Selection Syntax

ArcQL Query Language – Token Selection Syntax

ArcQL (Arc Query Language) is AgetnticOS’s query language for selecting tokens from places. Every transition preset uses ArcQL to specify which tokens to consume, making it fundamental to understanding how tokens agentic through your Petri nets.

Key Rule: All paths must start with $ (the root) and use == (double equals) for equality. String values use double quotes.

ArcQL Query Anatomy FROM $ WHERE $.status==”active” LIMIT 5 FROM $ select from $. path prefix WHERE filter clause $.field==”val” == + double quotes LIMIT 5 max tokens

Every ArcQL query follows this structure: FROM $ WHERE condition LIMIT n


Basic Query Syntax

// Select ALL tokens (no filter)
FROM $

// Filter by field value
FROM $ WHERE $.status=="active"

// Numeric comparison
FROM $ WHERE $.amount > 100

// Multiple conditions (AND)
FROM $ WHERE $.status=="pending" AND $.priority=="high"

// Limit results
FROM $ WHERE $.type=="order" LIMIT 10

// Order by field
FROM $ ORDER BY $.timestamp DESC LIMIT 5

Critical Syntax Rules

Common ArcQL Mistakes WRONG status=’pending’ single = and quotes status==”active” missing $ prefix $.status==active missing quotes $.status=’active’ single quotes CORRECT $.status==”pending” $ + == + “” $.status==”active” double equals $.amount > 100 numbers: no quotes $.active == true booleans: no quotes

Syntax Reference Table

Element Syntax Example Field path Must start with $. $.status, $.data.name Equality Double equals == $.status==”active” Strings Double quotes “…” $.name==”John” Numbers No quotes $.amount > 100 Booleans No quotes $.active == true Logical AND, OR $.a==”x” AND $.b>10

Token Structure in ArcQL

Token Structure: data vs _meta Token Object “data”: { … } “orderId”: “ORD-123”, “amount”: 99.99, “status”: “active” User-defined fields “_meta”: { … } “id”: “uuid-123…”, “name”: “order-token-1”, “parentId”: “place-uuid” System metadata

Accessing Token Fields

// Access user data (most common)
FROM $ WHERE $.data.status=="active"
FROM $ WHERE $.data.orderId=="ORD-123"
FROM $ WHERE $.data.amount > 100

// Access metadata
FROM $ WHERE $._meta.name=="special-token"
FROM $ WHERE $._meta.type=="Leaf"

Using ArcQL in Inscriptions

{
  "presets": {
    "input": {
      "placeId": "order-queue",
      "host": "my-model@localhost:8080",
      "arcql": "FROM $ WHERE $.data.status==\"pending\" LIMIT 1",
      "take": "FIRST",
      "consume": true
    }
  }
}

JSON Escaping: When writing ArcQL in JSON inscriptions, double quotes must be escaped with backslash:

// In JSON, escape inner double quotes with backslash
"arcql": "FROM $ WHERE $.data.status==\"active\""

// The actual query is:
// FROM $ WHERE $.data.status=="active"

take Semantics in Presets

take Values “FIRST” Takes first matching Process one at a time “ALL” Takes all matching Batch processing “LIMIT” Takes up to LIMIT Bounded batch

Quick Reference

// ================================
// ArcQL QUICK REFERENCE
// ================================

// Basic selection
FROM $                                    // All tokens
FROM $ LIMIT 1                            // First token

// Equality (strings)
FROM $ WHERE $.data.status=="active"      // $ prefix + == + ""

// Equality (numbers)
FROM $ WHERE $.data.amount > 100          // Numbers: no quotes

// Equality (booleans)
FROM $ WHERE $.data.active == true        // Booleans: no quotes

// Nested access
FROM $ WHERE $.data.customer.name=="John"

// Multiple conditions
FROM $ WHERE $.data.status=="pending" AND $.data.priority=="high"
FROM $ WHERE $.data.status=="active" OR $.data.status=="pending"

// Ordering
FROM $ ORDER BY $.data.timestamp DESC
FROM $ ORDER BY $.data.priority LIMIT 5

// In JSON inscription (escape quotes)
"arcql": "FROM $ WHERE $.data.status==\"pending\""

Summary

  • $ prefix – All field paths start with $
  • Double equals – Use == for equality (not single =)
  • Double quotes – String values use "..." (not single quotes)
  • Nested access – Use dot notation: $.data.customer.name
  • Logical operatorsAND, OR for complex conditions
  • LIMIT – Control how many tokens to return
  • ORDER BY – Sort results before limiting

Leave a Reply

Your email address will not be published. Required fields are marked *