Skip to content

^R D3: migrate scripts/workcell runtime/gc invariants from verify-invariants.sh to Go#401

Merged
omkhar merged 3 commits into
mainfrom
d3/workcell-runtime-invariants-go
Jul 5, 2026
Merged

^R D3: migrate scripts/workcell runtime/gc invariants from verify-invariants.sh to Go#401
omkhar merged 3 commits into
mainfrom
d3/workcell-runtime-invariants-go

Conversation

@omkhar

@omkhar omkhar commented Jul 5, 2026

Copy link
Copy Markdown
Owner

D3 (migrate verify-invariants.sh to Go) — increment 4 of N. Follows #398/#399/#400. Migrates the 10 scripts/workcell runtime/gc invariant checks (trusted-docker-client seed, DOCKER_CONFIG, buildx, the runtime_build_codex_arch musl-arch group, the self-docker/staging probes, the --gc cleanup pair, strict-mode-rebuild rejection, and the two go_colimautil validators).

What

  • internal/workcellhardening: new CheckRuntimeInvariants(rootDir) reusing the shared evaluate() + existing kinds. Adds two kinds: kindFunctionBlockAbsent (for the negated runtime_build_codex_arch sub-condition — unknown-linux-gnu present inside the block is a violation) and kindRegexPresent (symmetric with kindRegexAbsent).
  • cmd/workcell-citools: new workcell-runtime-invariants subcommand.
  • scripts/verify-invariants.sh: block replaced by go_verify_citools workcell-runtime-invariants "${ROOT_DIR}" || exit 1 at the same location.

Parity (identical pass/fail)

The runtime_build_codex_arch group (2 present + 1 negated function-block probe under one message) is expressed as ordered checks sharing that message — a test proves unknown-linux-gnu inside the block fails while outside the block passes (scoping guard). The strict-mode --rebuild. pattern is matched as a regex (rg treats the trailing . as any-char); every other pattern is metachar-free after unescaping → fixed-string. Verified: real repo → exit 0; crafted violations (DOCKER_CONFIG pinned, buildx removed, gnu-in-block) → exit 1 byte-identical.

Validation

go build/vet/gofmt, full go test ./... (table-driven, fixture per check + scoping guard), shellcheck -x, shfmt -d — all green. 4 files.

🤖 Generated with Claude Code

omkhar and others added 3 commits July 5, 2026 19:29
Re-implement the contiguous block of ten scripts/workcell runtime/gc
invariant checks (trusted Docker client seed, DOCKER_CONFIG-not-pinned
guard, buildx_cmd invocation, the runtime_build_codex_arch musl/gnu
release-asset guard, the hidden self-docker/self-staging probes, the
--gc runtime-image/temp cleanup pair, the strict-mode rebuild rejection,
and the two go_colimautil validators) as CheckRuntimeInvariants in
internal/workcellhardening, reusing the shared evaluate() driver and the
existing check kinds.

Add a kindFunctionBlockAbsent kind for the negated sub-condition of the
runtime_build_codex_arch guard (a gnu asset present inside the block is a
violation): the shell joined two affirmative function_block_contains_fixed
probes with one negated probe under a single message, expressed here as
two kindFunctionBlock checks plus one kindFunctionBlockAbsent check
sharing that message. Every rg pattern in the block is metacharacter-free
after unescaping, so each reduces to fixed-string containment.

Expose it through a new workcell-citools workcell-runtime-invariants
ROOT_DIR subcommand (inert until verify-invariants.sh is wired to it).
Table-driven tests cover the happy path plus one failing fixture per
check, including the musl group (missing musl arch and a gnu asset inside
the block both fail; a gnu asset outside the block does not) and the
DOCKER_CONFIG pin.

(byte-identical parity proven vs the shell on the real repo and crafted
violations, full go test + vet + gofmt green; primary D3 check-group
migration)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace the inline block of ten scripts/workcell runtime/gc invariant
checks (between the SSH-collision check and the start_managed_profile
mount function-block group) with a single go_verify_citools
workcell-runtime-invariants "${ROOT_DIR}" || exit 1 call plus a D3
comment. The || exit 1 preserves the former block's exit-1-on-violation
so the top-level ERR trap does not fire and append trap diagnostics, and
go_verify_citools already strips go run's exit-status trailer, keeping
the failure stderr byte-identical to the originals.

(shellcheck -x / shfmt / bash -n green, byte-identical parity proven on
happy and crafted-violation paths; supporting shell wiring for the D3
migration above)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… (the migrated 'strict mode requires --prepare ... --rebuild.' check used fixed-string containment, but rg treats the trailing . as any char; added a kindRegexPresent kind - symmetric with kindRegexAbsent - and switched that one check to it, so it matches exactly what rg -q would; every other pattern in the block stays fixed-string) (go test/shellcheck green, parity-exact; supporting D3 migration fidelity)
@omkhar

omkhar commented Jul 5, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 5fead2a3ab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@omkhar omkhar merged commit 3f6855a into main Jul 5, 2026
13 of 14 checks passed
@omkhar omkhar deleted the d3/workcell-runtime-invariants-go branch July 5, 2026 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant