feat(runner): add the own code runner contract, client and nsjail service
This commit is contained in:
1 parent
5e1db37746
commit
cdf6bcbb91
109 files changed
+24084
-28
No files matched your search
+26
-2
@@ -26,9 +26,9 @@ The project brief assigns 35% of its score to matching, 25% to assessment and ca
|
||||
|
||||
## Contracts and code generation
|
||||
|
||||
The contract roots are split by boundary: api/core/ contains browser-to-Go operations, and api/ml/ contains internal Go-to-ML operations. The shared Makefile, package.json, and Redocly configuration stay under api/. Python schema tools live in the repository-level scripts/ directory. Each contract is assembled from small source YAML files.
|
||||
The contract roots are split by boundary: api/core/ contains browser-to-Go operations, api/ml/ contains internal Go-to-ML operations, and api/runner/ contains internal operations between Go and the code runner. The shared Makefile, package.json, and Redocly configuration stay under api/. Python schema tools live in the repository-level scripts/ directory. Each contract is assembled from small source YAML files.
|
||||
|
||||
The public Go handler is generated by ogen from backend/codegen/ogen.yml and mounted in chi. Orval independently generates the TypeScript client, TanStack Query hooks, Zod schemas, and MSW handlers. The ML Go client is configured at backend/codegen/ogen-ml.yml and generated into backend/internal/adapter/secondary/ml/api/. datamodel-code-generator produces Pydantic v2 models from the same ML bundle in ml/src/lincodex_ml/api/models.py; the health/readiness handlers use these models. Python generator settings live in ml/codegen/pyproject.toml, while dependencies remain in ml/pyproject.toml. Backend sqlc configuration is backend/codegen/sqlc.yml and its generated SQL adapter is under backend/internal/adapter/secondary/postgres/sqlc/. Frontend configuration is frontend/codegen/orval.config.ts. There are three codegen directories: backend/codegen/, frontend/codegen/, and ml/codegen/. Configuration belongs to the service that uses the generated code.
|
||||
The public Go handler is generated by ogen from backend/codegen/ogen.yml and mounted in chi. Orval independently generates the TypeScript client, TanStack Query hooks, Zod schemas, and MSW handlers. The ML Go client is configured at backend/codegen/ogen-ml.yml and generated into backend/internal/adapter/secondary/ml/api/, and the code runner Go client is configured at backend/codegen/ogen-code-runner.yml and generated into backend/internal/adapter/secondary/code_runner/api/. datamodel-code-generator produces Pydantic v2 models from the same ML bundle in ml/src/lincodex_ml/api/models.py; the health/readiness handlers use these models. Python generator settings live in ml/codegen/pyproject.toml, while dependencies remain in ml/pyproject.toml. Backend sqlc configuration is backend/codegen/sqlc.yml and its generated SQL adapter is under backend/internal/adapter/secondary/postgres/sqlc/. Frontend configuration is frontend/codegen/orval.config.ts. There are three codegen directories: backend/codegen/, frontend/codegen/, and ml/codegen/. Configuration belongs to the service that uses the generated code.
|
||||
|
||||
OpenAPI 3.2.0 is the target version. Verify the subset used here across bundling and lint, ogen, the chi adapter, the API runtime path, Orval, Python Pydantic models, and documentation. A parser version or one fixture does not prove support for every OpenAPI 3.2.0 feature.
|
||||
|
||||
@@ -537,6 +537,7 @@ The local release manifest separates core image verification from product data a
|
||||
```text
|
||||
api/core/ public browser-to-Go contract and bundle
|
||||
api/ml/ internal Go-to-ML contract and bundle
|
||||
api/runner/ internal Go-to-code-runner contract and bundle
|
||||
backend/cmd/app/main.go calls bootstrap.Run and reports errors
|
||||
backend/cmd/migrate/ local migration status, up, and down-one
|
||||
backend/config/ shared runtime configuration
|
||||
@@ -551,6 +552,7 @@ frontend/src/ app, pages, widgets, features, entities, shared
|
||||
frontend/codegen/ Orval configuration
|
||||
ml/src/ FastAPI service and operational checks
|
||||
ml/codegen/ Python datamodel-code-generator settings
|
||||
runner/ Go code runner service: nsjail, cgroup v2, judge, and HTTP API
|
||||
deploy/ Compose, Nginx, and technical smoke checks
|
||||
observability/ Prometheus, Loki, Alloy, Grafana provisioning
|
||||
scripts/ shared documentation and schema tooling
|
||||
@@ -586,6 +588,7 @@ backend/
|
||||
mail/resend/ mail transport that sends one request to the Resend HTTP API per message
|
||||
mail/resend/resendfixture/ local stand-in for the Resend API, for tests only; production never imports it
|
||||
ml/api/ generated client from backend/codegen/ogen-ml.yml
|
||||
code_runner/api/ generated client from backend/codegen/ogen-code-runner.yml
|
||||
postgres/ pool, migrator, transactor, outbox writer and relay store, event consumer store, identity, consent ledger, organization, membership, and policy repositories, health check
|
||||
postgres/sqlc/ generated SQL adapter
|
||||
redis/ cache adapter and Redis check
|
||||
@@ -720,6 +723,27 @@ A category changes only by a strict grade upgrade (the database trigger and the
|
||||
|
||||
`basis` is the same value as the `source` of the category decision. Today it is always `synthetic_demo`: the database accepts only the demonstration source and `calibration_status = uncalibrated`. The candidate card and the organization search therefore show such a category as a demonstration, not as a validated measurement. The basis is required in every category object, so a category without a basis cannot look like a standard confirmation.
|
||||
|
||||
### Code runner
|
||||
|
||||
Code practice runs in the own `runner/` service; Judge0 is not used (GPL license, owner decision). The service receives the source, the limits, and the test groups through the internal `api/runner/` contract, runs every test in nsjail, and returns the outcome of every group. The backend computes the 0-3 score from the three hidden groups; the runner only reports which groups passed.
|
||||
|
||||
The A16 boundary. Untrusted code runs only on a separate runner host. The target production placement is a dedicated LXD VM on the app host (2 vCPU, 3 GB, one concurrent run) attached to a private bridge without internet access; the backend reaches it over TLS with a bearer token. A privileged container on the core host is forbidden, and a Docker network alone is not a boundary. The runner host holds no business secrets: only its TLS key and the API token.
|
||||
|
||||
Isolation layers of one run (implemented):
|
||||
|
||||
- nsjail in run-once mode: new network (empty, without loopback), PID, mount, IPC, UTS, user, and cgroup namespaces, `no_new_privs`, dropped capabilities, the user uid/gid 99999 inside and outside the user namespace, and no `/proc`.
|
||||
- File system: the jail root is a read-only tmpfs; only `/usr` and `/lib` (the interpreter) are mounted read-only, the run directory with the source is mounted read-only as `/box`, plus `/dev/null` and `/dev/urandom`, and the working directory `/tmp` is a size-limited tmpfs. The run directory is removed after the run, and its root is emptied at startup.
|
||||
- cgroup v2: the supervisor creates the cgroup of every run itself (`memory.max` with a small allowance for nsjail, `memory.swap.max=0`, `pids.max`, `cpu.max` for one CPU) and starts nsjail directly inside it with CLONE_INTO_CGROUP. The limits therefore cover the whole process tree, and the OOM, refused fork, and CPU counters are exact.
|
||||
- rlimits: CPU, file size, open files, core 0, and address space.
|
||||
- seccomp (kafel): the process is killed on ptrace, mount and namespace calls, keyrings, bpf, perf, userfaultfd, io_uring, kernel modules, and clock and swap administration; clone with namespace flags kills the process, clone3 answers ENOSYS, and sockets other than AF_UNIX answer EAFNOSUPPORT.
|
||||
- The supervisor checks CPU, wall clock, OOM, and the process limit every 10 ms and, when a limit fires, kills the jailed processes but keeps nsjail so that it reaps its child; if nsjail does not exit within a second, the whole cgroup is killed. After a run the cgroup is removed only once it is empty.
|
||||
|
||||
The service bounds concurrent runs (1 by default) and answers 503 `runner_busy` when no slot is free; the backend keeps the queue. The contract and the configuration bound the request body, the source, the inputs, and the output. Logs carry only the method, operation, status, duration, run ID, language, group and test counts, and outcome; the source, test data, program output, and token never reach a log. Runs live only in memory and are forgotten after their TTL; the backend resubmits a run lost in a restart.
|
||||
|
||||
Outcomes distinguish `accepted`, `wrong_answer`, `compile_error` (for Python, a syntax check with `compile()` before the tests), `time_limit_exceeded`, `memory_limit_exceeded`, `output_limit_exceeded`, `runtime_error` (including the process limit), and `infrastructure_failure`. Test time is the CPU time of every process of the test, including interpreter startup; memory is the cgroup peak of the test, including nsjail and file cache charged to the test.
|
||||
|
||||
Planned and not implemented: deployment of the runner VM with TLS, firewall, and monitoring; Go (compile and run); a float tolerance checker and custom checkers; calls from the backend and the run queue; service metrics; the full A16 isolation suite built on `runner/testdata/hostile/`.
|
||||
|
||||
## Matching and explanations
|
||||
|
||||
Implemented as a deterministic search without ML: `POST /api/v1/organizations/{org_id}/matches` (`SearchOrganizationMatches`, [api/README.en.md](../../api/README.en.md#match-search)). Code: the usecase `backend/internal/usecase/matching/` (`search.go` the flow, `filter.go` the filters, `score.go` the integer scoring, `explain.go` the explanation), the card list `candidateview.Service.ListVisibleCards`, the policy section `domain.MatchingPolicy` (`policy_matching.go`), the skill relations `domain.RelateEvidenceSkill` (`evidence_relation.go`), the handler `adapter/primary/http/v1/matches.go`, and the wiring `bootstrap/matches.go`. There is no new table, migration, or query file: the search reuses the barrier queries that the card and the evidence already use, so there is one copy of the visibility rule.
|
||||
|
||||
@@ -735,6 +735,44 @@ Verified on the app host (TASK-592): from a guest on `lxdbr-runner` the internet
|
||||
|
||||
Cleanup before the rollout removed only the Docker build cache (`docker builder prune -af`, about 8 GB). `apt-get clean` and `journalctl --vacuum-size=100M` need sudo and are left to the operator. Docker volumes, the images of the running stack, `wg0`, `awg-lincodex` and the `ufw` rules are not touched.
|
||||
|
||||
## Code runner
|
||||
|
||||
The `runner/Dockerfile` image holds the Go supervisor, nsjail, and Python from `python:alpine`; pip and ensurepip are removed. The base images are the `GO_IMAGE` and `RUNTIME_IMAGE` arguments, so a release build can pin their digests. The supervisor runs as root inside its own host or VM because it needs namespaces, user mapping, and writes to its delegated cgroup. Candidate programs run as uid 99999 without capabilities.
|
||||
|
||||
### Local (development only)
|
||||
|
||||
`deploy/docker/docker-compose.runner.dev.yml` is a separate dev project `runner-dev`. It gives the container `privileged: true`, because nsjail needs namespaces and a writable cgroup v2 tree inside the Docker Desktop VM, and it serves plain HTTP on 127.0.0.1 only. The file is never used by a release or in production; `make -C deploy check-runner-dev` checks that its switches stay out of the other Compose files, the production image, and the release tooling.
|
||||
|
||||
make -C deploy runner-dev-config
|
||||
make -C deploy runner-dev-up
|
||||
make -C deploy runner-dev-logs
|
||||
make -C deploy runner-dev-down
|
||||
|
||||
`runner-dev-up` creates a local random token in `runner/.dev/api-token` (ignored by Git) when it is missing and starts the service on `127.0.0.1:${RUNNER_DEV_HTTP_PORT:-8070}`. Call it with `Authorization: Bearer $(cat runner/.dev/api-token)` and `PUT /v1/runs/<uuid>` from the `api/runner/` contract.
|
||||
|
||||
### Production (planned)
|
||||
|
||||
The runner runs only in the `lincodex-runner` VM on the `lxdbr-runner` bridge (see [the isolated runner host](#isolated-runner-and-lab-host-lxd)), never on the core host and never with the dev file. TLS (`RUNNER_TLS_CERT_FILE`, `RUNNER_TLS_KEY_FILE`; the process does not start without them) and a token from a secret file (`RUNNER_API_TOKEN_FILE`) are required. Rolling out the VM, issuing the certificate, storing the token for the backend, and monitoring are not implemented yet.
|
||||
|
||||
| Variable | Default | Purpose |
|
||||
| --- | --- | --- |
|
||||
| `RUNNER_LISTEN_ADDRESS` | `:8443` | HTTP(S) address |
|
||||
| `RUNNER_TLS_CERT_FILE`, `RUNNER_TLS_KEY_FILE` | none | TLS 1.3 certificate and key; required outside dev |
|
||||
| `RUNNER_API_TOKEN_FILE` or `RUNNER_API_TOKEN` | none | Token of at least 32 characters; prefer the file |
|
||||
| `RUNNER_DEV_ALLOW_PLAINTEXT_HTTP` | `false` | Dev Compose only: HTTP without TLS |
|
||||
| `RUNNER_MAX_CONCURRENT_RUNS` | `1` | Concurrent runs; more answer 503 `runner_busy` |
|
||||
| `RUNNER_MAX_REQUEST_BYTES` | `8388608` | Request body limit |
|
||||
| `RUNNER_RESULT_TTL`, `RUNNER_MAX_RETAINED_RUNS` | `15m`, `256` | In-memory result retention |
|
||||
| `RUNNER_RETRY_AFTER`, `RUNNER_SHUTDOWN_TIMEOUT` | `2s`, `30s` | Retry-After when busy and the wait for runs at shutdown |
|
||||
| `RUNNER_WORK_DIR` | `/var/lib/lincodex-runner/work` | Run directories; emptied at startup, tmpfs recommended |
|
||||
| `RUNNER_CGROUP_ROOT` | `/sys/fs/cgroup` | The service's delegated cgroup v2 |
|
||||
| `RUNNER_NSJAIL_PATH`, `RUNNER_PYTHON_PATH` | `/usr/bin/nsjail`, `/usr/local/bin/python3` | Paths in the image |
|
||||
| `RUNNER_SANDBOX_UID` | `99999` | Program user, never root |
|
||||
| `RUNNER_SANDBOX_MAX_PROCESSES` | `16` | Processes and threads of a run |
|
||||
| `RUNNER_SANDBOX_MEMORY_OVERHEAD_BYTES` | `4194304` | Memory allowance for nsjail above the task limit |
|
||||
| `RUNNER_SANDBOX_TMPFS_BYTES`, `RUNNER_SANDBOX_FILE_SIZE_BYTES`, `RUNNER_SANDBOX_OPEN_FILES` | `16777216`, `8388608`, `64` | `/tmp` size, file size, and open files |
|
||||
| `RUNNER_LOG_LEVEL` | `info` | JSON log level |
|
||||
|
||||
## Services and images
|
||||
|
||||
Container images use moving `latest` or `alpine` tags where the upstream publishes them. Check the current Compose references when updating the stack. These tags can move; the [release manifest](#release-manifest) records the actual image digests of a release. An SBOM is not produced yet. Application dependency lockfiles remain checked in separately.
|
||||
@@ -752,6 +790,7 @@ Container images use moving `latest` or `alpine` tags where the upstream publish
|
||||
| PostgreSQL exporter | prometheus-community/postgres_exporter | Apache-2.0 |
|
||||
| Docker socket proxy | Tecnativa/docker-socket-proxy | Apache-2.0 |
|
||||
| BusyBox | busybox | GPL-2.0-only |
|
||||
| nsjail | Alpine `nsjail` package in the code runner image | [Apache-2.0](https://github.com/google/nsjail/blob/master/LICENSE) |
|
||||
|
||||
Upstream references: [PostgreSQL image](https://github.com/docker-library/postgres), [Prometheus](https://github.com/prometheus/prometheus/blob/main/LICENSE), [Loki license details](https://github.com/grafana/loki/blob/main/LICENSING.md), [Alloy license details](https://github.com/grafana/alloy/blob/main/LICENSING.md), [Grafana license details](https://github.com/grafana/grafana/blob/main/LICENSING.md), [node_exporter](https://github.com/prometheus/node_exporter/blob/master/LICENSE), [postgres_exporter](https://github.com/prometheus-community/postgres_exporter/blob/master/LICENSE), [socket proxy](https://github.com/Tecnativa/docker-socket-proxy), [BusyBox license](https://busybox.net/license.html).
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ What exists now:
|
||||
- Health and readiness routes. Nginx answers `GET /healthz` itself and proxies only `/api/` to Go (deploy/nginx/conf.d/app.conf). Go serves `GET /healthz` (`ok`) and `GET /readyz` (`ready` or 503 `not_ready` after checking PostgreSQL, Redis, and SeaweedFS) on its internal port 8080 outside the OpenAPI contract, plus `GET /api/v1/healthz` from api/core/routes/healthz.yml through the ogen handler (backend/internal/adapter/primary/http). The Go metrics listener uses port 9090 (`METRICS_ADDR`) and Prometheus scrapes `/metrics`. ML serves `GET /healthz`, `GET /readyz` (always 503 `not_ready` because no model is connected), and `/metrics` (ml/src/lincodex_ml, api/ml/routes). deploy/scripts/smoke.sh checks Nginx `/healthz`, `/api/v1/healthz`, Go `/readyz` from inside the Compose network, a 404 for an unknown API route, and that the backend started with `EMAIL_PROVIDER=disabled`; it does not start ML or send mail.
|
||||
- Adapters: PostgreSQL through pgxpool with a generated `SELECT 1` query, a goose migration runner applied at startup, a transactor with the transactional outbox writer, sqlc-backed identity repositories for accounts, email tokens, and sessions, and the versioned policy repository with the demo policy seed at startup; Redis through go-cachekit, and SeaweedFS through the S3 API. The Argon2id password hasher and `identity.Credentials` are wired for registration and email confirmation. A generated Go client for the ML contract exists but is not wired into bootstrap.
|
||||
- Mail: the outbound `MailSender` port, the `disabled` and `resend` transports, and the `EMAIL_PROVIDER` selection in bootstrap; `smtp` stops startup after its settings are validated. Product notification requests (`mail_requests`) are turned into deliveries (`deliveries`, `delivery_attempts`) by the `notification_delivery` consumer, but notification sending is not implemented. With `resend`, the backend runs a worker for identity service mail: registration and resend queue verification messages bound to their tokens; the worker checks the token and account before sending and uses a quota gate and stable idempotency key. Password reset is not implemented yet. See [DEPLOY.md](DEPLOY.md#mail) and [ARCHITECTURE.md](ARCHITECTURE.md#mail-deliveries).
|
||||
- OpenAPI contracts api/core/ and api/ml/ with schema merge, bundles, lint, and generation for Go (ogen), TypeScript (Orval), and Python (datamodel-code-generator). The SPA uses the generated API client; MSW handlers provide test data. Implemented forms are listed below, while remaining routes still show placeholders.
|
||||
- OpenAPI contracts api/core/, api/ml/, and api/runner/ with schema merge, bundles, lint, and generation for Go (ogen), TypeScript (Orval), and Python (datamodel-code-generator). The SPA uses the generated API client; MSW handlers provide test data. Implemented forms are listed below, while remaining routes still show placeholders.
|
||||
- Compose projects: core (`deploy/docker/docker-compose.yml`: PostgreSQL, Redis, SeaweedFS, Kafka, backend, frontend), ML (`docker-compose.ml.yml`), and monitoring (`docker-compose.monitoring.yml`).
|
||||
- Kafka: one KRaft node in the core Compose project with an internal-only listener, a named volume, a health check, and a memory limit. The backend runs the outbox relay, which creates the `lincodex.domain.events` topic and publishes committed outbox events to it through a franz-go producer; see [Outbox relay](#outbox-relay). Readiness does not check Kafka. The event consumer runtime runs two product handlers, the mail delivery consumer and the inbox consumer, and no product flow emits their events yet; see [Event consumers](#event-consumers).
|
||||
- CI jobs in .github/workflows/ci.yml: `api`, `backend`, `integration` (matrix of two shards), `frontend`, `ml`, `codegen`, `infrastructure`, `security`, `security-images`, `smoke`, `e2e` (Playwright suite on an isolated stand), and the required `aggregate` result, which fails when any of them fails, is cancelled, or is skipped. See [TESTING.md](TESTING.md) for sharding and the browser suite.
|
||||
@@ -100,22 +100,24 @@ Each top-level directory except `.github/` has a short Russian `README.md` and a
|
||||
| --- | --- |
|
||||
| api/core/ | Public browser-to-Go OpenAPI contract |
|
||||
| api/ml/ | Internal Go-to-ML OpenAPI contract |
|
||||
| api/runner/ | Internal OpenAPI contract between Go and the code runner |
|
||||
| scripts/ | Shared schema merge, generated drift, and docs-check |
|
||||
| backend/ | Go HTTP service, adapters, bootstrap, SQL, and consumer codegen |
|
||||
| backend/config/ | Shared Go configuration outside internal |
|
||||
| frontend/ | Vite SPA, Orval configuration, generated TypeScript |
|
||||
| ml/ | Python service, lockfile, and Pydantic model generator |
|
||||
| runner/ | Go code runner service: nsjail, cgroup v2, judge, ogen server, and isolation tests |
|
||||
| deploy/ | Compose, Nginx, and smoke script |
|
||||
| observability/ | Prometheus, Loki, Alloy, provisioning, and dashboard JSON |
|
||||
| security/ | Scanner configuration, installation, Make targets, and local reports |
|
||||
| .agents/ | Canonical project instructions and working standards |
|
||||
| docs/ru/, docs/en/ | User documentation in Russian and English |
|
||||
|
||||
Codegen directories belong to the services that use the generated code: backend/codegen/, frontend/codegen/, and ml/codegen/. The Go client for the internal ML API is generated from backend/codegen/ogen-ml.yml and consumed at backend/internal/adapter/secondary/ml/api/. The public Go handler is generated from backend/codegen/ogen.yml and mounted in chi. sqlc configuration is backend/codegen/sqlc.yml, with generated SQL under backend/internal/adapter/secondary/postgres/sqlc/. Orval reads the public bundle from frontend/codegen/orval.config.ts. backend/cmd/app/main.go calls bootstrap.Run() and handles its error; startup, dependency wiring, and lifecycle logic live in backend/internal/bootstrap/app.go.
|
||||
Codegen directories belong to the services that use the generated code: backend/codegen/, frontend/codegen/, and ml/codegen/. The Go client for the internal ML API is generated from backend/codegen/ogen-ml.yml and consumed at backend/internal/adapter/secondary/ml/api/. The Go client for the code runner is generated from backend/codegen/ogen-code-runner.yml into backend/internal/adapter/secondary/code_runner/api/. The public Go handler is generated from backend/codegen/ogen.yml and mounted in chi. sqlc configuration is backend/codegen/sqlc.yml, with generated SQL under backend/internal/adapter/secondary/postgres/sqlc/. Orval reads the public bundle from frontend/codegen/orval.config.ts. backend/cmd/app/main.go calls bootstrap.Run() and handles its error; startup, dependency wiring, and lifecycle logic live in backend/internal/bootstrap/app.go.
|
||||
|
||||
## Contracts and generation
|
||||
|
||||
Source YAML stays beside its contract. Run make -C api bundle to merge schemas separately for api/core/ and api/ml/ and then bundle both inputs. The public and internal APIs remain separate contracts.
|
||||
Source YAML stays beside its contract. Run make -C api bundle to merge schemas separately for api/core/, api/ml/, and api/runner/ and then bundle each input. The public and internal APIs remain separate contracts.
|
||||
|
||||
Root make generate prepares both bundles once, then runs Go, TypeScript, and Python consumers. Merged schemas, bundles, and generated clients are tracked derived files; change their sources and regenerate them. After changing a contract, regenerate every consumer and check drift. A service-local Make target can generate one consumer when its inputs are ready and the shared contract owner has agreed.
|
||||
|
||||
|
||||
@@ -581,6 +581,20 @@ What these tests do not show: a real invitation event through Kafka and the rela
|
||||
|
||||
The tests do not run the Make targets against a real stack. A manual check on a throwaway project: `make -C deploy demo-seed DEMO_MODE=isolated DEMO_PROJECT=lincodex-demo-check DEMO_HTTP_PORT=18090` twice with identical inventories, a sign-in of the prepared accounts with mail disabled, an express run and the start of the full test, then `demo-reset` refused after a visitor registered. Remove the project afterwards with `docker compose -p lincodex-demo-check down --volumes` and the same variables. The tests do not validate the content of the synthetic bank or any grade, and the browser route of the jury is not covered here. Integration tests need Docker.
|
||||
|
||||
## Code runner tests
|
||||
|
||||
| Command | What it checks |
|
||||
| --- | --- |
|
||||
| make -C runner test | Unit tests with the race detector: checkers, configuration, judge outcomes on a scripted sandbox, idempotency and busy handling of the run manager, the HTTP API (token, 202/200/422/503, 400, 413, 404), and that logs carry no source, input, or token |
|
||||
| make -C runner lint | golangci-lint for Linux, including the isolation tests |
|
||||
| make -C runner check-generated | The generated ogen server matches the bundle |
|
||||
| make -C runner test-sandbox | Isolation tests in a privileged dev container with real nsjail and cgroup v2 |
|
||||
| make -C deploy check-runner-dev | Dev switches stay out of production files |
|
||||
|
||||
`test-sandbox` runs every case of `runner/testdata/hostile/manifest.json` twice: a correct solution is accepted with its time and memory recorded; a syntax error gives `compile_error`; the CPU limit stops an infinite loop, the wall-clock limit a sleep, the cgroup memory limit a memory leak, the output limit endless output, and the process limit a fork bomb (`runtime_error`); network, file system, and privilege probes confirm that there is no network, the root and the source are read-only, runner files are not visible, and the program is not root. After every case and after the series the test checks that the run directory is empty, the run cgroups are gone, and no uid 99999 process is left. It runs without a separate init, so it also confirms that nsjail reaps every stopped process.
|
||||
|
||||
What the tests do not prove: isolation in the production VM (they have not run there yet), protection against kernel, nsjail, or cgroup vulnerabilities, the absence of side channels, or behavior under load. The full A16 isolation suite is planned separately and will extend the same fixtures.
|
||||
|
||||
## Future software validation
|
||||
|
||||
Go unit tests should exercise domain/usecase rules with explicit inputs, results, and errors. Integration tests should use a real PostgreSQL at the same major version, apply goose migrations, and exercise sqlc, constraints, transactions, rollback, and concurrent transitions. The HTTP path should use chi, middleware, usecases, and the database; replace external ML with a controlled HTTP fake and email with a test adapter.
|
||||
|
||||
Reference in new issue
Block a user