x-lang

← Index

x/tool/contract

Shared scaffold for the in-language gate ratchets, on the Contract class: the sorted recursive walk, sorted-list set ops (sort/uniq/only), the tool’s own argv behind the engine prefix, and the allocation guard.

Gates run from the repo root (make provides the cwd), so walk paths are repo-relative by construction; the shell policy that homed the gates in the language is tools/README.md.

Class Contract

Shared scaffold for the in-language contract gates (tools/check/*.x): sorted file walks, sorted-list set difference, and entry-script argv/allocation plumbing.

(Contract walk dir keep?)

Every file under dir (recursive) whose repo-relative path satisfies keep?, sorted by byte order – the find DIR | sort replacement.

Parameters:

Returns: LIST — Sorted path strings

(Contract sort xs)

xs sorted ascending by byte order. Deliberately locale-free: shell sort output depends on the host locale, byte order does not.

Parameters:

Returns: LIST — Sorted list

Examples:

(Contract sort (list "b" "a" "c")) => ("a" "b" "c")
(Contract sort (list "a" "_" "B")) => ("B" "_" "a")

(Contract uniq xs)

Adjacent duplicates removed (with sort, sort -u).

Parameters:

Returns: LIST — Deduplicated list

Examples:

(Contract uniq (list "a" "a" "b")) => ("a" "b")

(Contract only as bs)

Members of as absent from bs, in order (merge walk; both inputs sorted and deduplicated).

Parameters:

Returns: LIST — as minus bs

Examples:

(Contract only (list "a" "b" "c") (list "b")) => ("a" "c")

(Contract argv)

The tool’s own arguments: (Sys args ‘program) without the engine’s path – what follows the “–” x.sh writes after its own options.

Returns: LIST — Argument strings

(Contract alloc-guard!)

Arm alloc-limit! from X_ALLOC_LIMIT_OBJS – default 300000000, non-numeric values fall OPEN to the default: the same contract as the spec harness and the shell gates it replaces.