Cyber Sequence
Language.

Write scripts, watch event streams, and define what happens when a rule fires.

How ranks work

The proposed Sequence system starts at 9 and ends at 0. Each step unlocks a new function set and keeps all the sets already unlocked.

Sequence 6
Can use sets 9, 8, 7, and 6. Promoting to Sequence 5 adds the reusable ability functions.

Function sets

PROPOSED API

Select a Sequence to see its five new functions. These signatures describe the rank design and are pending implementation.

Quick start

From the interpreter repository, build CSL and start its interactive prompt. Enter len("CSL") to see 3.

Terminal
./build.sh
./run

To run a file, use ./run path/to/script.csl. Save this example as score.csl to try a function call.

score.csl
fun withBonus(points) {
    if (points >= 3) return points + 2;
    return points;
}

print withBonus(3); // 5

Script basics

Values
Numbers, double-quoted strings, booleans, nil, and functions. Only false and nil are falsey.
Variables
Declare with var score = 0; and assign with score = 5;. Braces create a local scope.
Operators
Use + - * / for arithmetic, comparisons such as >=, and !, and, and or for logic. + also joins strings.
Control flow
Use if, else, while, and for. Use // for line comments.
Functions
Declare with fun. A function can close over variables in its enclosing scope. A bare return; or reaching the end yields nil.
Built-ins
len(text) counts Unicode code points. typeOf(value) returns "number", "string", "boolean", "nil", or "function". These are ordinary script functions outside the rank system.

Watches & abilities

A watch selects a source, counts matching events within a rolling window, and runs a sequence when the count reaches the threshold.

examples/failed-signins.csl
watch failedSignIns {
    source "signins";
    count "failed_signin" by "account" within 60 >= 3;
    sequence {
        alert "Review repeated sign-in failures";
    }
}

This rule alerts when an account reaches three failures within 60 seconds. Each account has a separate count. A rule can fire again after old events expire and the count crosses the threshold again.

Replay sample events
./run examples/failed-signins.csl < examples/signins.jsonl

Watch files read one JSON object per input line. Send integer timestamps in seconds, in nondecreasing order per source, and put group values in the fields object. With a single named source, events may omit source.

Example event
{"source":"signins","kind":"failed_signin","timestamp":40,"fields":{"account":"ana"}}

Reuse a sequence

Declare a named ability and use sequence summarizeSignIns; in a watch to call it. Ability steps run in the order you write them.

review-signins.csl
ability summarizeSignIns {
    target "local-report";
    require capability "report:review";
    sequence {
        inspect;
        alert "Review repeated sign-in failures";
    }
}

watch failedSignIns {
    source "signins";
    count "failed_signin" by "account" within 60 >= 3;
    sequence summarizeSignIns;
}

Capability grants

CSL checks the target and required capability when the watch program starts. To run the ability above, save the file and pass a grant for its target and capability.

Terminal
./run review-signins.csl --grant local-report report:review < examples/signins.jsonl

In the proposed rank system, the rank unlocks an operation and the host grant authorizes it for a specific target. The current ability syntax uses inspect; for a summary and emits simulated intent records for isolate; and execute;.