In fact, the binary was fine. The code signature was not.
Diagnosis
A quick check with codesign revealed the real culprit:
Check the binary code signature
$ codesign -vv ./opencode
./opencode: invalid or unsupported format for signature
In architecture: arm64
On Apple Silicon, macOS enforces code signing strictly. A malformed or corrupt LC_CODE_SIGNATURE load command will cause the kernel to terminate the process immediately with SIGKILL (Killed: 9)—before a single line of your code runs.
You can confirm the signature load command exists with otool:
Confirm the code-signature load command
$otool-l./opencode|grepLC_CODE_SIGNATURE
cmdLC_CODE_SIGNATURE
The Fix
Remove the broken signature and replace it with a local ad-hoc signature: