Skip to content

Latest commit

 

History

History
183 lines (154 loc) · 10.7 KB

development.md

File metadata and controls

183 lines (154 loc) · 10.7 KB

Developing Callosum

Local module settings

Give each daemon test rig its own config home and write its settings to <config home>/cortexkit/callosum.jsonc. Seed paired devices, permission groups and trust in that rig's Callosum store. Announce only when the test covers mDNS: otherwise set /network/announce_on_local_network to false.

Private test services that deliberately use plaintext must opt in on the Callosum process: set CALLOSUM_ALLOW_INSECURE_ENROLLMENT=1 for HTTP enrollment or CALLOSUM_ALLOW_INSECURE_RELAY=1 for a relay without TLS. These are startup flags, not settings, and each generates a startup warning. Do not set them on deployed modules.

Daemon rigs built with fault-hooks can set CALLOSUM_TEST_LIMITS to one JSON object of exact internal limits, for example {"max_body_bytes":4096,"default_deadline_ms":3200}. It accepts max_in_flight, max_subscriptions, max_body_bytes, keepalive_interval_ms, default_deadline_ms, reconnect_grace_ms, ledger_dispatch_max_ms, ledger_retention_grace_ms, max_ledger_rows_per_peer, and max_ledger_bytes_per_peer. Unknown keys are refused. The environment value is read at startup and overrides the corresponding settings-derived values in test builds only. The production binary does not recognize the variable.

Vendored cross-repo vectors: drift check

Run python3 test-vectors/scan-vendored-ids.py (--verbose for per-file counts). CI runs this check too. The scanner checks the snapshots in this repository, not the current files in the producing repositories.

Producer-generated vectors check what another implementation actually emits, rather than what Callosum expects it to emit. Each vendored corpus records its source repository, commit, path and family in its source block. The consuming tests' every_vendored_case_has_a_consumer checks catch a vendored case with no consumer, but they cannot catch a producer adding cases that are not yet vendored.

What the scanner checks

Module IDs can occur inside base64url-encoded JWS payloads. A plaintext search cannot see them. The scanner checks plaintext as well as IDs found by two independent methods: walking three-segment JWS tokens and decoding their payloads, and sweeping for base64-looking segments without assuming a token shape. The segment sweep must find every ID the token walk found. It can find more: an unsigned token has an empty signature segment, so the three-segment walk misses it.

The scanner refuses an empty allowlist, unknown module IDs, or a scan that finds no IDs or only synthetic ones. Synthetic control tokens check that both discovery methods can find a known retired ID. The controls use realistic segment lengths so they exercise the same discovery logic as the corpora.

Compare against producer corpora

Before a release or after a producer reports a corpus change:

  1. Run find test-vectors -type f and identify every file with a source block. Do not rely on a producer's list of the corpora it believes Callosum vendors.
  2. Read each source block, verify the full 40-character commit hash, and compare the vendored family with the current family in the producer checkout.
  3. Treat any difference as producer drift. Deterministic values such as iat and jti prevent incidental changes when the vectors are regenerated.
  4. Re-vendor new cases and add a consumer for each. For a changed case, check whether the producer changed a contract or corrected a fixture before updating.

Add a vector consumer

  • Exercise the stages the production consumer runs, and assert which stage rejected a bad case rather than only asserting that something rejected it.
  • Assert that a refused input was not partially applied. Truncating an over-limit set is not a refusal.
  • Run an acceptance case before the refusal cases, so a consumer that refuses every input cannot pass.
  • For signed families, verify at the corpus's verification_times, not the wall clock. Assert the signature verifies before testing a refusal that depends on later checks. Pure-data families do not need a clock.

Landing and deploying

The gate scripts below submit their work as a job to a remote Linux build service through ck motor run, and the local machine only submits and streams logs. If you don't have access to that service, set CALLOSUM_LOCAL=1 to run scripts/quick-check.sh or scripts/local-gates.sh on your own machine. Their daemon end-to-end lanes still submit through scripts/e2e-remote.sh; on Linux, run scripts/e2e-gates.sh directly instead.

Run scripts/quick-check.sh [base] (default origin/master) for changed-crate tests, formatting, workspace Clippy and scans. Quick check snapshots the working tree and resolves the base before submitting the job. Session, call-path, store/schema and test-harness changes also select the daemon end-to-end suites. The protected paths are in scripts/lib/quick_check.py.

To deploy on macOS, commit on local master, then run scripts/deploy-local.sh from a clean tree on that branch. Unpushed commits are allowed, so you can observe a change before the full gates; the script warns when the deployed commit is not pushed yet. The script builds the release binary locally and places a copy, not a symlink into target/, in ~/.local/share/cortexkit/bin. It signs the copy with an Apple Development identity, hardened runtime and no entitlements. Hardened runtime stops another process of the same user from attaching a debugger and reading the launch nonce out of callosum's memory. The team identity keeps macOS privacy grants, such as Local Network access for router discovery and mDNS, across rebuilds. Set CK_CALLOSUM_SIGN_IDENTITY to choose the identity; otherwise the script uses the keychain's Apple Development identity and refuses if there is none or more than one. The script checks the signing flags on the placed file, restarts the module, and then checks the running process: it is healthy, reports HEAD as its build, runs the placed file, and refuses a debugger attach. There is no Linux or Windows deploy script. Watch ck module status callosum and ck --json provenance callosum, and exercise the phone call path. The script can roll back only when the backup binary supports the current store schema.

After verifying the deployment, run scripts/remote-gate.sh HEAD for the exact-commit Linux gate and scripts/e2e-remote.sh for the daemon end-to-end suites, then push. To check the working tree, scripts/local-gates.sh [--e2e] also submits to the Linux build service. The --e2e and quick-check end-to-end lanes run scripts/e2e-gates.sh directly in that job. Do not set CALLOSUM_IN_JOB=1 on the submitting machine; the wrappers set it inside the remote job to prevent nested submissions.

The submission wrappers use scripts/lib/motor_submit.sh. By default it finds subconscious next to the repository, including when run in a linked worktree; set SUBCONSCIOUS_ROOT to override discovery. It snapshots the sibling using ck motor run --sibling and sets SUBCONSCIOUS_ROOT and CALLOSUM_SUBC_TARGET_DIR=$PWD/target/subc in the job so the daemon builds outside the read-only sibling snapshot.

The wrappers stream suite logs and return the suites' exit code. They retry refused submissions (ck motor run exit 200) and reattach to the same job after connection loss (exit 201); they never restart a job that ran and failed or fall back to a local build. scripts/remote-gate.sh uses a clean checkout outside the repository; set CALLOSUM_GATE_DIR to choose its location. The build service rejects nested workspaces. scripts/e2e-gates.sh is the standalone Linux entry point for the daemon suites. Full gates print timings and log paths and fail if any stage fails.

Linux does not compile #[cfg(target_os = "macos")] code. For changes to those paths, opt into a native check with CALLOSUM_LOCAL=1 scripts/quick-check.sh [base] or CALLOSUM_LOCAL=1 scripts/local-gates.sh. Selected daemon end-to-end suites still run through scripts/e2e-remote.sh.

Native CI on every release target

ci.yml tests natively on each of the five release targets, for the same triggers as Test (ubuntu), including pushes to train/** and master: Test (windows-x64) on windows-latest, Test (windows-arm64) on windows-11-arm, Test (linux-arm64) on ubuntu-24.04-arm and Test (darwin-arm64) on macos-latest. Each job first checks that the runner's architecture and Rust host match its target, so nothing is cross-compiled. Test (ubuntu) also runs formatting, the path-dependency and internal-file checks, Clippy in the dev and release profiles, the vendored vector scan, and the two-daemon loopback suite (two_daemon_e2e::). The macOS and Linux ARM64 jobs run cargo test --locked --workspace --all-targets. The Windows jobs run cargo clippy --locked --workspace --all-targets -- -D warnings and cargo test --locked --workspace with native Windows Rust, not WSL. Every job has a 180-minute timeout, and the Windows Cargo cache is SHA-pinned and keyed by runner OS, architecture, lockfile and compiler version. The Release workflow builds assets only for a commit whose push CI passed all five (see docs/release.md).

scripts/train-push.sh delegates the landing verdict to scripts/watch-ci.sh, which checks the whole workflow, so failures on Windows block landing too. Run both scripts with WATCH_CI_WORKFLOW=ci.yml in this repository; their default is tests.yml. The train precondition checker (scripts/check-train-preconditions.sh) enforces the Windows cache rules and the shared trigger, condition, concurrency and timeout rules. It accepts a github.event_name condition only on the Release workflow's tag-only publish job.

The normal test command does not run the #[ignore] daemon end-to-end suites. They need a ck-subc build from a sibling subconscious checkout and POSIX process-group teardown. Run them on Linux with scripts/local-gates.sh --e2e or scripts/e2e-gates.sh. CI runs only the two-daemon loopback suite, on Test (ubuntu). Windows CI tests the non-ignored suite, not Windows daemon installation, router discovery or WAN probes.

Windows directory synchronization is a no-op: file bytes are synced before publication and NTFS rename is atomic, but a newly created directory entry may be lost after an immediate power cut. Unix directory sync is unaffected. The retirement journal retains the Windows read access needed for locking, and pairing confirmation reads through the locked handle because Windows byte-range locks deny reads from a second handle.

.gitattributes preserves committed fixture bytes and Rust source LF line endings, so structural checks can match exact source lines. The Ubuntu and Windows test jobs print git ls-files --eol for the pinned files and compare checked-out fixture bytes against the index.