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

(Contract uniq xs)

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

Parameters:

Returns: LIST — Deduplicated list

(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

(Contract argv)

The tool’s own arguments: args minus the engine path and the engine flags x.sh -f prepends (–batch/–quiet/–no-color). Tool flags after x.sh’s -- survive untouched.

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.