Executable Go, Node and Python examples behind the corrected Production AI Automation Notes index. Each package demonstrates a narrow contract and its failure fixtures. These examples are independent of a production service; no provider credentials are required to test them.
Requirements: Go 1.24+, Node 22+, Python 3.13+, Bash 4+, Linux/Unix for flock. Go dependencies are pinned in go.mod/go.sum. Tests use temporary files and localhost endpoints. They never send external messages, invoke an attack command or contact paid inference APIs.
go test -race ./...
node --test node/*.test.mjs
python3 -m unittest discover -s tests -v| Example | What the fixtures check | Limits |
|---|---|---|
| node/serve.mjs | JSON remains argv, invalid jobs/child errors fail the batch | Fixed operator CLI/allowlist; destination permissions remain separate |
| python/drain.py | Immutable batches, durable completed IDs, uncertain starts held | One host; no automatic replay of ambiguous external effects |
| python/exec_guard.py | Malformed input blocks, DNS patterns, package commands, canonical cwd | Pattern tripwire, not a shell parser or sandbox |
| python/approval.py | Action/payload/target/version/expiry binding, revocation, insert failure | Local authorization/outbox, not proof of external delivery; provider CAS needed |
| python/conditional_write.py | Persisted ETags and atomic SQLite version checks across processes | One document; permission checks and remote effects remain separate |
| node/tool-result.mjs | Missing/invalid tool calls, task assertions and bounded model-only alternatives | Explicit acceptance fixture, not an automatic LiteLLM plugin or tool dispatcher |
| python/budget.py | Atomic concurrent token/currency reservations and settlement | Caller must bound all billed components; not integrated into draftcat |
| node/retrieval.mjs | Hung/rejected branches settle by deadlines; signals cancel | Ignored cancellation may leave work running; semantic-only results may be lost |
| python/acl.py | Current permission checks, revoked provenance and visible counts | Remote permission/load atomicity requires provider snapshots |
| python/embedding_width.py | Actual vector width and malformed-shape rejection | Ollama endpoint; equal width is not equal vector space |
| shell/ndjson-deploy.sh | Quotes/newlines are valid JSON; monotonic durations | Source as Bash functions; service list is whitespace-delimited |
| shell/health-check-cron.sh | Checks during cooldown, immediate recovery, unknown status unhealthy | Private operator-owned state and endpoint configuration |
| go/* | Rate capacity, parse failures, cancellation, bounded handlers, publisher failures, UTC keys | See each package's source; helper guarantees do not imply durable delivery |
Redis Pub/Sub is at-most-once. A retained failed batch can duplicate if a failed command reached Redis. The publisher reports errors; it does not create durable retries. Redis quota tests cover validation/UTC keys; a live Redis deployment is not exercised by the offline suite.
SQLite FULL relies on a filesystem honoring sync/locking. Unit tests do not simulate a hardware power cut. An approval/outbox row is distinct from an external effect, and a caller-attested outcome is distinct from independently observed execution. Keep uncertain outcomes until reconciled.
Run the localhost HTTP example with no credentials:
python3 python/conditional_write_demo.py
python3 -m unittest discover -s tests -p test_conditional_write.py -vThe demo refuses stale/weak tags with 412 and a missing condition with 428. Two writers holding one version produce one success and one refusal. The tests also use separate processes and reopen the SQLite file to check persisted versions. The HTTP wrapper is a teaching fixture on loopback, not a production web service. It accepts one exact ETag, rejects wildcard/list requests by endpoint policy, and does not implement approvals, authentication or idempotent external delivery.
node --test node/tool-result.test.mjsrequireToolUse checks one required Anthropic-format call against a supplied input
validator. requireTaskSuccess separately checks tool execution and task assertions.
acceptedModelResponse demonstrates at most two caller-allowed model destinations
under one deadline, before any tool is executed. It does not install a LiteLLM hook
or replay a failed/uncertain external action. See the tests for provider errors,
200-with-prose, wrong arguments, task failure and a hanging response.
- HTTP If-Match and 412: stop stale agent writes after approval — atomic target-version checks preserve a newer human edit; includes a runnable HTTP race fixture.
- JSONL CLI runners and immutable batches
- Claude Code PreToolUse tripwire
- Action-bound approval evidence
- Bounded retrieval branches
- Permission-aware retrieval
Include a small failing input, runtime/version and desired contract. Use synthetic data; remove credentials and customer records. Follow @renezander030 for the accompanying tested notes. MIT licensed.
The startup helper and mock process-ownership tests maintain the corrected example from the archived local-ai-coding-stack repository. It never downloads a model, requires LOCAL_MODEL, clears a conflicting Anthropic API key and refuses to reuse an existing server with unknown context. Run bash local/startup.test.sh. No successful fresh hardware coding benchmark is claimed.