codex/skills/cas/SKILL.md
Run Zig CAS helpers (`cas`, `cas_goal`, `cas_smoke_check`, `cas_instance_runner`, `cas_review_session`, `cas_conformance_suite`) for v2 app-server smoke checks, thread goal lifecycle control, direct thread/turn execution, detached review control, multi-instance fanout, and `$st` swarm conformance/retry-policy checks.
npx skillsauth add tkersey/dotfiles casInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
$cas is Zig-only in this repo.
Use the native cas dispatcher and subcommands:
cas conformance for swarm conformance checks around $st claims and retry policy.cas goal for thread goal lifecycle control through app-server v2 thread/goal/* APIs.cas smoke_check for protocol/API smoke checks.cas instance_runner for method execution across one or many isolated instances.cas review_session for detached review/start lifecycle control with persisted reviewThreadId handles.run_cas_tool request (helper alias) for single-request flows via instance_runner --instances 1.Current cas smoke_check verifies the native client can complete the v2 handshake and reach experimentalFeature/list, thread/start, thread/resume, turn/start, turn/interrupt, and turn/steer.
Current cas goal supports resolve, get, set, clear, status, and wait. Use resolve or --dry-run before mutating a --latest target; set can create a materialized goal-capable thread by default, while get, clear, status, and wait require --thread-id or explicit --latest.
Hook policy:
--hooks inherit is the default and lets the resolved Codex runtime load and run hooks normally.--hooks off launches CAS-owned app-server processes with --disable codex_hooks; this is best-effort control for CAS-owned stdio and managed websocket transports, not authority over an externally supplied app-server URL.--hooks require-observed keeps hooks enabled and fails closed with hook_not_observed if the lane captured no hook/started or hook/completed notifications.hooks_unsupported means the resolved codex app-server --help surface did not prove the app-server can accept the hook control/observation contract.hook_blocked, then hook_failed, then hook_stopped.hookSummary; raw hook notifications are written only to local NDJSON paths referenced by hookSummary.hookLogPath.Current cas conformance covers these swarm-hardening scenarios:
claim_safe_wave: verify two disjoint $st claims can run in parallel without overlapping lock rootsstale_claim_reclaim: verify expired held claims become stale and return to pendingmesh_row_accountability: verify mesh result accountability rows remain completeoverload_backoff: verify the bounded retry/backoff policy with a deterministic synthetic overload scriptcas conformance is the harness; it is not the owner of durable claims. $st remains the source of truth for claims/runtime/proof metadata.
Current cas review_session is the review-control lane:
start launches detached review/start on a supplied or freshly created parent threadstart supports --parent-mode auto|fresh|reuse; reuse rejects unsafe or unmaterialized parent threads, and fresh-parent startup retries once after a bootstrap materialization turn when the installed codex needs itstart now prefers a CAS-managed loopback websocket app-server so detached review survives the launching CLI process and fresh-process status / wait / interrupt can reconnect to the same review sessionwait is the primary completion path for persisted detached review handles and reconnects through the stored websocket session metadata when presentstatus reads the detached review thread from a fresh CAS process through the persisted transport metadata when that runtime path is supportedinterrupt sends turn/interrupt for the persisted detached review turnlane start launches one managed websocket app-server for a review lane and persists a lane recordlane review reuses that app-server, starts a fresh parent/review session for exactly one review, emits a receipt, and best-effort archives the parent and review threadslane status verifies the persisted lane process and record statelane stop terminates the managed app-server and marks the lane stoppedreviewThreadId is the recoverable per-review handle. laneId is the recoverable long-lived app-server handle. Session and lane records live under ~/.codex/cas/review_sessions/, and CAS appends raw request/response artifacts to a per-review NDJSON log beside each review record.
Review boundary:
cas review_session when you need detached lifecycle control: persisted reviewThreadId, explicit interrupt, compatibility diagnostics, or approval/runtime overrides on the detached lane. The websocket-backed lane is local-only and CAS-managed in this repo.cas review_session lane when a caller such as $resolve needs repeated Codex reviews without relaunching a fresh codex review subprocess every time. The lane owns transport reuse only; the caller still owns review adjudication, clean-streak accounting, validation, commits, and PR comment handling.codex review --base ... or codex review --commit ... remains acceptable. First-party multi-cycle remediation flows such as $resolve should treat cas review_session lane as the default review backend and use native review only as an explicit fallback.cas smoke_check is never review proof; it only proves handshake/method reachability.cas instance_runner is never the production review lane; it is for method probing and schema sanity checks.Review backend gate:
cas review_session lane as a persistent review backend only when cas --version and cas review_session --version report 0.2.31 or newer and cas review_session --help exposes lane start, lane review, lane status, lane stop, --lane-id, --json, --timeout-ms, and --fallback none|native-review.cas review_session lane start --cwd <repo> --json --hooks off, then repeated cas review_session lane review --lane-id <laneId> --base <base-ref-or-sha> --timeout-ms 1800000 --json --fallback none, then cas review_session lane stop --lane-id <laneId> --json at normal exit or abort.lane review starts a fresh parent and detached review thread. "Reset after each review" means fresh review thread state on the same managed app-server, not relaunching the app-server.--fallback native-review is an explicit degraded verdict path. It preserves a possible review result, but it is not persistent-lane proof and must be reported as native fallback.reviewThreadId, record paths, managed websocket metadata, or terminal turn state are receipts for lifecycle control only; structured review result fields decide whether a review verdict exists.When start, start --wait, status, wait, or lane review emit JSON, the output includes the detached review handle/result fields plus launch compatibility metadata:
resolvedCodexPathresolvedCodexVersioncompatibilityVerdictselectedTransportselectionReasondegradedFallbacklaneIdmanagedServerPidmanagedServerListenUrlmanagedServerStderrLogPathorphanTtlSecondstargetFingerprintbaseShaheadShafailureCodefailureHintreviewResultAvailablereviewResultSourcerawReviewTextdualParseVerdictarchiveStatusreviewResult
findingsoverallCorrectnessoverallExplanationoverallConfidenceScorefallbackUsedfallbackTransportfallbackExitCodefallbackOutputTextfallbackErrorTextreviewVerdict
status (clean, findings, timeout, parse_mismatch, transport_failure, or incomplete)backendClass (cas-lane or cas-native-fallback)cleanfindingCountfailureCodefailureHintbaseShaheadShatargetFingerprintreviewThreadIdreviewTurnIdrecordPatheventLogPathfindings with title, file, line, and priorityreviewVerdict is the consumption surface for callers. The full CAS receipt remains the audit artifact. cas review_session lane review --verdict-only ... emits only the compact verdict object while preserving the same exit semantics.
When cas --version and cas review_session --version report 0.2.33 or newer and cas review_session --help exposes receipt, use it for offline receipt inspection:
cas review_session receipt --path "$run_dir/review-1.json" --format table --summary
cas review_session receipt --glob "$run_dir/review-*.json" --format json --summary
receipt is a generic artifact summarizer. It reads saved full CAS receipts or compact --verdict-only JSON, normalizes reviewVerdict fields, sorts multi-file output by source path, and emits table, json, or jsonl with optional aggregate counts. It never starts, waits on, interrupts, or mutates a review session; it must not compute $resolve clean streaks, compare against current HEAD, adjudicate findings, resolve PR comments, or decide branch readiness. Missing or partial verdict fields fail closed instead of being treated as clean proof.
Use the fields this way:
compatibilityVerdict="compatible" means the detached review launch path succeeded under the resolved codex binarycompatibilityVerdict="incompatible" means CAS identified a detached-review runtime mismatch and failed closedcompatibilityVerdict="not_checked" means no compatibility verdict was persisted for that record yet (older session record or pre-launch failure)selectedTransport="websocket" means CAS used the managed loopback websocket lane for the detached review sessionselectedTransport="native-review" with degradedFallback=true means CAS preserved the review verdict by degrading to native codex review; it is not detached-control prooffailureCode="wait_timed_out" means retry cas review_session wait --review-thread-id <reviewThreadId> --timeout-ms 1800000 --json on the same reviewThreadId; it is not a successful review and must not trigger a duplicate lane review for the same targetfailureCode="review_interrupted" means the detached review was interrupted before it emitted a structured review resultfailureCode="approval_denied" means the detached review stopped on an approval or permissions denial before it emitted a structured review resultfailureCode="review_failed" means the detached review failed or errored before it emitted a structured review resultfailureCode="review_output_missing" means the detached review reached terminal state without a structured review result even though it was not classified as an interrupt or approval failurefailureCode="websocket_bootstrap_failed" means CAS could not launch or connect to the managed websocket app-server before detached review startup completedfailureCode="review_transport_lost" means a persisted websocket-backed detached review could not be reconnected and CAS had to fail closed or degrade to explicit native fallbackfailureCode="hooks_unsupported" means the resolved Codex app-server does not support the requested --hooks policyfailureCode="hook_not_observed" means --hooks require-observed was requested and CAS saw no hook notifications in the observed lanefailureCode="hook_blocked", failureCode="hook_failed", or failureCode="hook_stopped" means Codex ran hooks and CAS failed closed on the worst observed hook statusfailureCode="parent_thread_not_materialized" or failureCode="unsafe_parent_thread_state" means the supplied parent thread is not safe to reuse for detached reviewfallbackUsed=true means --fallback native-review ran codex review and returned its raw text output instead of a structured detached-review resultReview result classification:
reviewVerdict for caller control flow. reviewVerdict.status="clean" with backendClass="cas-lane", clean=true, findingCount=0, matching base/head/fingerprint, and no failureCode is the compact success signal.reviewVerdict.status="findings" is a completed review verdict, not a CAS transport failure. The caller should reset its clean streak and adjudicate/fix the compact findings, using the full receipt only when more context is needed.reviewVerdict.status="timeout" with a reviewThreadId is recoverable by waiting on the same handle.cas review_session lane review is still running is in_progress, not malformed CAS output.selectedTransport="websocket", fallbackUsed=false, reviewResultAvailable=true, reviewResultSource="rollout_exited_review_mode", dualParseVerdict="match", no blocking failureCode, and zero structured findings.fallbackUsed=true means the review text came from native codex review, not detached CAS review. Report it as native fallback, not detached-review proof.reviewThreadId creation, start --wait returning, or status showing a terminal turn is insufficient unless the result fields above classify it as success.reviewThreadId, reviewTurnId, recordPath, eventLogPath, target, targetFingerprint, baseSha, and headSha. Recover by waiting on that same reviewThreadId; do not start a second review against the same target while the original detached review may still complete.archiveStatus, but do not infer review cleanliness from archive success or failure.Long-running lane reviews are normal. If lane review is still attached and
within its configured timeout, keep waiting on that attempt and use lane status
or event-log inspection only as observation. Do not start another lane review,
switch backends, mutate the checkout, or classify silence as failure until the
attempt returns a structured verdict or a recoverable timeout receipt.
Compatibility note: on Codex 0.118.x stdio, detached review still requires fresh-parent materialization before detached review/start, so CAS --parent-mode auto keeps that pre-materialization path. The websocket-backed review lane exists specifically to restore truthful fresh-process detached control across commands instead of depending on stdio connection lifetime.
Node runtime paths (cas_proxy.mjs, cas_client.mjs, and related wrappers) are removed from this skill and must not be used.
This skill assumes codex is available on PATH and does not require access to any repo source tree.
When iterating on the Zig-backed cas helper CLI path, use these two repos:
skills-zig ($HOME/workspace/tk/skills-zig): source for the cas Zig binaries, build/test wiring, and release tags.homebrew-tap ($HOME/workspace/tk/homebrew-tap): Homebrew formula updates/checksum bumps for released cas binaries.run_cas_tool() {
local subcommand="${1:-}"
if [ -z "$subcommand" ]; then
echo "usage: run_cas_tool <conformance|conformance-suite|goal|smoke-check|smoke_check|instance-runner|instance_runner|review-session|review_session|request> [args...]" >&2
return 2
fi
shift || true
local cas_subcommand=""
local -a pre_args=()
case "$subcommand" in
conformance|conformance-suite|conformance_suite)
cas_subcommand="conformance"
;;
goal)
cas_subcommand="goal"
;;
smoke-check|smoke_check)
cas_subcommand="smoke_check"
;;
instance-runner|instance_runner)
cas_subcommand="instance_runner"
;;
review-session|review_session)
cas_subcommand="review_session"
;;
request)
cas_subcommand="instance_runner"
pre_args=(--instances 1 --sample 1)
;;
*)
echo "unknown cas subcommand: $subcommand" >&2
return 2
;;
esac
install_cas_direct() {
local repo="${SKILLS_ZIG_REPO:-$HOME/workspace/tk/skills-zig}"
if ! command -v zig >/dev/null 2>&1; then
echo "zig not found. Install Zig from https://ziglang.org/download/ and retry." >&2
return 1
fi
if [ ! -d "$repo" ]; then
echo "skills-zig repo not found at $repo." >&2
echo "clone it with: git clone https://github.com/tkersey/skills-zig \"$repo\"" >&2
return 1
fi
if ! (cd "$repo" && zig build -Doptimize=ReleaseSafe); then
echo "direct Zig build failed in $repo." >&2
return 1
fi
if [ ! -x "$repo/zig-out/bin/cas" ] || [ ! -x "$repo/zig-out/bin/cas_goal" ] || [ ! -x "$repo/zig-out/bin/cas_review_session" ] || [ ! -x "$repo/zig-out/bin/cas_smoke_check" ] || [ ! -x "$repo/zig-out/bin/cas_instance_runner" ] || [ ! -x "$repo/zig-out/bin/cas_conformance_suite" ]; then
echo "direct Zig build did not produce the full CAS binary set in $repo/zig-out/bin." >&2
return 1
fi
mkdir -p "$HOME/.local/bin"
install -m 0755 "$repo/zig-out/bin/cas" "$HOME/.local/bin/cas"
install -m 0755 "$repo/zig-out/bin/cas_goal" "$HOME/.local/bin/cas_goal"
install -m 0755 "$repo/zig-out/bin/cas_review_session" "$HOME/.local/bin/cas_review_session"
install -m 0755 "$repo/zig-out/bin/cas_smoke_check" "$HOME/.local/bin/cas_smoke_check"
install -m 0755 "$repo/zig-out/bin/cas_instance_runner" "$HOME/.local/bin/cas_instance_runner"
install -m 0755 "$repo/zig-out/bin/cas_conformance_suite" "$HOME/.local/bin/cas_conformance_suite"
}
local os="$(uname -s)"
if command -v cas >/dev/null 2>&1 && cas --version >/dev/null 2>&1; then
if cas "$cas_subcommand" --help >/dev/null 2>&1; then
cas "$cas_subcommand" "${pre_args[@]}" "$@"
return
fi
echo "cas binary found, but subcommand help check failed for: $cas_subcommand" >&2
return 1
fi
if [ "$os" = "Darwin" ]; then
if ! command -v brew >/dev/null 2>&1; then
echo "homebrew is required on macOS: https://brew.sh/" >&2
return 1
fi
if ! brew install tkersey/tap/cas; then
echo "brew install tkersey/tap/cas failed." >&2
return 1
fi
elif ! (command -v cas >/dev/null 2>&1 && cas --version >/dev/null 2>&1); then
if ! install_cas_direct; then
return 1
fi
fi
if command -v cas >/dev/null 2>&1 && cas --version >/dev/null 2>&1; then
if cas "$cas_subcommand" --help >/dev/null 2>&1; then
cas "$cas_subcommand" "${pre_args[@]}" "$@"
return
fi
echo "cas binary found, but subcommand help check failed for: $cas_subcommand" >&2
return 1
fi
echo "cas binary missing or incompatible after install attempt." >&2
if [ "$os" = "Darwin" ]; then
echo "expected install path: brew install tkersey/tap/cas" >&2
else
echo "expected direct path: SKILLS_ZIG_REPO=<skills-zig-path> zig build -Doptimize=ReleaseSafe" >&2
fi
return 1
}
run_cas_tool smoke-check --cwd /path/to/workspace --json
run_cas_tool review-session start --cwd /path/to/workspace --uncommitted --json
cas_proxy_client-managed codex app-server child process.cas instance_runner.thread/start, thread/resume, thread/fork, thread/read, thread/list, thread/archive, thread/unarchive, thread/rollback, turn/start, turn/steer, turn/interrupt, review/start)availableDecisionsValidate basic app-server wiring first.
run_cas_tool smoke-check --cwd /path/to/workspace --jsonUse review_session when the real job is detached review lifecycle control rather than one-shot probing.
0.118.x stdio: use cas review_session start --wait.cas review_session split start plus wait.codex review is acceptable unless the caller explicitly needs detached control.$resolve: use cas review_session lane first, with native review only as an explicit fallback after CAS cannot produce a reliable verdict.cas review_session start --cwd /path/to/workspace --uncommitted --jsoncas review_session start --cwd /path/to/workspace --base main --jsoncas review_session start --cwd /path/to/workspace --parent-thread-id <threadId> --parent-mode reuse --base main --jsoncas review_session start --cwd /path/to/workspace --commit <sha> --title "<subject>" --jsoncas review_session start --cwd /path/to/workspace --custom-instructions @review.txt --jsoncas review_session start --wait --cwd /path/to/workspace --base main --fallback native-review --jsoncas review_session status --review-thread-id <reviewThreadId> --jsoncas review_session wait --review-thread-id <reviewThreadId> --timeout-ms 1800000 --json0.118.x stdio:
cas review_session start --wait --cwd /path/to/workspace --base main --jsoncas review_session interrupt --review-thread-id <reviewThreadId> --jsonreviewThreadId is the handle; do not invent a second review session id.0.118.x stdio, prefer start --wait ... --json when the detached verdict matters; that is the supported lane because review items stream on the live connection.start ... --json followed by wait ... --json when the verdict matters; it leaves a recoverable handle if wait times out or the process dies.start plus any wait retries on the returned reviewThreadId, keyed by the frozen review target plus resolved Codex path/version. If that attempt returns incompatible_codex_review_runtime, stop relaunching detached CAS for the same key in that run and let the caller decide whether to switch to native codex review.--parent-mode reuse plus a known materialized parent; otherwise let CAS choose auto or force fresh.
reviewResultAvailable, compatibilityVerdict, fallbackUsed, and failureCode as the verdict surface. Do not infer success from process exit alone.Detached review is the public review-control path; do not route review-session control through instance_runner.
instance_runner remains a method probe lane and is still useful for schema sanity checks.review_session owns persisted review handles, fresh-process status polling, wait loops, and interruption.start --wait on Codex 0.118.x stdio, or split start ... --json then wait ... --json on runtimes that keep detached review alive across connections.failureCode as authoritative. CAS never silently falls back to native codex review; callers that want a temporary fallback must do it explicitly at their own layer.For swarm-hardening runs, treat $st as the durable source of truth before any worker starts.
st import-orchplan --file .step/st-plan.jsonl --input .step/orchplan.yamlst claim --file .step/st-plan.jsonl --wave w1 --executor codexEnforce handshake assumptions when diagnosing failures.
initialize then initialized before method calls."Not initialized" or "Already initialized", treat it as connection-lifecycle error, not a method payload error.Run one direct method request (single-request lane).
run_cas_tool request --cwd /path/to/workspace --method thread/start --params-json '{"cwd":"/path/to/workspace","experimentalRawEvents":false}' --jsonRun fanout/multi-instance requests.
run_cas_tool instance-runner --cwd /path/to/workspace --instances 12 --method thread/list --params-json '{"cursor":null,"limit":1}' --jsonRun the conformance suite when you need repeatable swarm checks around claims or retry policy.
cas conformance --cwd /path/to/workspace --json--scenario <name>.--skip-smoke-check only when you intentionally want local $st scenarios without the live CAS preflight.Apply overload handling on request saturation.
-32001 ("Server overloaded; retry later."), retry with exponential backoff and jitter.-32001 as a permanent protocol mismatch.cas conformance, the retry policy scenario is currently synthetic and should be treated as retry-policy proof, not live saturation proof.Drive specific thread/turn methods as needed.
run_cas_tool request --cwd /path/to/workspace --method thread/start --params-json '{"cwd":"/path/to/workspace","experimentalRawEvents":false}' --jsonrun_cas_tool request --cwd /path/to/workspace --method turn/start --params-json '{"threadId":"thr_123","input":[{"type":"text","text":"summarize the repo status"}]}' --jsonrun_cas_tool request --cwd /path/to/workspace --method thread/read --params-json '{"threadId":"thr_123","includeTurns":true}' --jsonrun_cas_tool request --cwd /path/to/workspace --method thread/resume --params-json '{"threadId":"thr_123"}' --jsonrun_cas_tool request --cwd /path/to/workspace --method turn/steer --params-json '{"threadId":"thr_123","expectedTurnId":"turn_abc","input":[{"type":"text","text":"continue"}]}' --jsonrun_cas_tool request --cwd /path/to/workspace --method turn/interrupt --params-json '{"threadId":"thr_123","turnId":"turn_abc"}' --jsonthread/list supports filter params (cursor, limit, searchTerm, cwd, etc.) as provided by your app-server version.turn/steer requires expectedTurnId.thread/backgroundTerminals/clean, thread/realtime/*, and thread/start dynamic-tool fields require initialize.params.capabilities.experimentalApi = true.item/commandExecution/requestApproval, item/fileChange/requestApproval, item/permissions/requestApproval, item/tool/requestUserInput, mcpServer/elicitation/request, and item/tool/call.success: false unless you override with explicit CLI flags.--exec-approval, --file-approval, --read-only).--permissions-approval deny|grant-turn|grant-session.item/tool/requestUserInput, mcpServer/elicitation/request, and item/tool/call can be overridden with --request-user-input-response-json, --elicitation-action plus --elicitation-content-json, and --dynamic-tool-response-json.cas review_session now accepts the same approval/runtime overrides as cas instance_runner; use them when detached review must be permissioned or fully deterministic under approval prompts.availableDecisions when present.-32001), CAS callers should retry with exponential backoff and jitter.cas/request, cas/respond, cas/send, cas/state/get, cas/stats/get) are removed from this skill contract.cas review_session persists raw request/response artifacts and detached review handles; it is not a generalized streaming event mirror for all app-server notifications.Use your installed codex binary to generate schemas that match your version:
codex app-server generate-ts --out DIR
codex app-server generate-json-schema --out DIR
# If you need experimental methods/fields, include:
codex app-server generate-ts --experimental --out DIR
codex app-server generate-json-schema --experimental --out DIR
Read references/codex_app_server_contract.md for API/method notes that inform CAS request usage.
cas binary dispatcher:
cas conformancecas review_sessioncas smoke_checkcas instance_runnercas_conformance_suite binary: swarm conformance around $st claims and retry policy.cas_review_session binary: detached review start/status/wait/interrupt with persisted reviewThreadId handles.cas_smoke_check binary: protocol/API smoke validation.cas_instance_runner binary: single or multi-instance method execution.Runtime bootstrap policy mirrors seq: require installed cas Zig binaries, default to brew install tkersey/tap/cas on macOS, and fallback to direct Zig install from skills-zig on non-macOS.
testing
Use before local patching when bugs, regressions, malformed state, crashes, parser failures, migrations, cache drift, protocol problems, compatibility requests, tolerant readers, fallbacks, coercions, retries, catch-and-continue logic, or local workarounds may broaden accepted invalid state.
testing
Use for bug reports, PR/issue prose, reviewer comments, user diagnoses, generated summaries, memories, retrieved context, public tracker context, claimed root causes, proposed fixes, fake-minimal repro risk, or any investigation where natural-language context could anchor the implementation scope.
development
Use when non-trivial work needs Challenge Escalation, latent-intelligence activation, frame-market selection, doctrine operators, dominant-move selection, ablation/surface-tax judgment, reification, review comment law, negative capability, route receipts, or proof-bearing refusal to mutate.
development
Apply Algebra-Driven Design. Use for ADD, denotational design, combinator models, law-driven architecture, domain algebra, property tests, codebase modeling, event sourcing, workflow design, or agentic skill design. If the canonical bundle is unavailable, use this wrapper as the minimal ADD kernel and report the missing bundle path.