Reliability expectations and invariants for Loong.
The public reader-facing summary for this material lives in
../site/reference/security-and-reliability.mdx.
This file remains the repository-native reliability and invariant reference.
| If you are trying to... | Start here |
|---|---|
| read the public summary first | ../site/reference/security-and-reliability.mdx |
| inspect repository-native invariants and verification expectations | this file |
| understand the broader repository docs layering | README.md |
- you need the source-level invariant and verification contract
- you are checking whether a change weakens an existing reliability guarantee
- you need the repository-native commands and guardrails behind the public summary
| Area | What this file covers |
|---|---|
| build invariants | CI-parity commands that must stay green |
| runtime guardrails | execution behavior that should not silently degrade |
| architecture guardrails | machine-checkable boundary and complexity rules |
| kernel and channel invariants | fail-closed and persistence behavior that should remain stable |
These must hold at every commit on every branch:
cargo fmt --all -- --checkpassescargo clippy --workspace --all-targets --all-features -- -D warningspassescargo test --workspacepassescargo test --workspace --all-featurespasses (test count evolves with the codebase; CI is the source of truth)
Enforced by: CI (.github/workflows/ci.yml, surfaced through the aggregate build check). The
optional scripts/pre-commit hook mirrors these cargo gates locally.
- Quick local loop β use
task verify:quickfor a faster edit/test cycle, ortask test:packages PACKAGES='-p loong-app -p loong-spec'when you want a targeted package subset. This lane keeps curated daemon smoke coverage but skips the heaviest integration suite and does not replace CI parity. When you are iterating inside daemon integration tests,task test:daemon:domainsgives you the optional sharded domain binaries andtask test:daemon:heavystill runs the canonical full integration binary. - Changed-package loop β use
task verify:changedto scope local Rust tests to the packages touched in the current working tree plus reverse dependents. When that closure includesloong, the loop still runs the curated daemon integration smoke subset by default and now escalates daemon test-file edits into the matching optional domain shards by reading the shard entry files as the source of truth, with a fallback to the fullintegrationbinary for broad harness changes. - CI parity β the
buildcheck runs workspace fmt/clippy, default workspace tests on Ubuntu and Windows, the all-features workspace test lane on Ubuntu, and explicit feature-delta compile checks forloong-spectest-hooksplus the browser-without-web.fetch app feature set. - Extended gate β
task verify:fulladds smoke and benchmark validation on top of the canonical local verification bar.
- Wasm trap behavior is platform-aware by default β on macOS,
signals_based_trapsis disabled to avoid trap-handler abort instability under parallel bridge tests. - Runtime override is explicit β set
LOONG_WASM_SIGNALS_BASED_TRAPS=true|falseto force trap behavior for diagnostics/experiments. - Daemon stress helper is scriptable β run
./scripts/stress_daemon_tests.sh 10 default,2,1for manual repeated daemon test validation across thread modes. - Trap-mode matrix is available when needed β set
LOONG_STRESS_WASM_TRAPS_MODES=auto,false,trueto sweep daemon tests across trap behavior modes during targeted investigation.
- Complexity budgets are machine-checkable β run
./scripts/check_architecture_boundaries.shdirectly, ortask check:architecturewhen the optionaltaskCLI wrapper is installed, to inspect module line/function budgets for architecture hotspots (spec_runtime,spec_execution,provider/mod,memory/mod,acp/manager,acp/acpx,channel/registry,config/channels,chat,channel/mod,conversation/turn_coordinator,tools/mod,daemon/lib,daemon/onboard_cli). The checker classifies each hotspot byfoundation,structural_size, andoperational_densitypressure so reviews can distinguish large-surface drift from runtime-density risk. - Memory operation literals are boundary-guarded β memory core operation strings (
append_turn,window,clear_session) must remain centralized incrates/app/src/memory/*and never spread into callsites. specstays detached fromappβ the architecture guardrails treat any directloong-appdependency incrates/spec/Cargo.tomlas a boundary regression, and./scripts/check_dep_graph.shmust stay green.- Strict enforcement is the blocking gate β use
LOONG_ARCH_STRICT=true ./scripts/check_architecture_boundaries.shdirectly, ortask check:architecture:strictwhen the optionaltaskCLI wrapper is installed, to make architecture budget violations fail non-zero. This check is part oftask verify,task verify:full, and CI.
- Token authorization is fail-closed β if the policy engine cannot determine authorization (e.g., mutex poisoned), the operation is denied.
- Audit events are never silently dropped β kernel sinks fail closed on write errors instead of silently downgrading. Production app bootstraps default to
FanoutAuditSinkbacked by~/.loong/audit/events.jsonl,LoongKernel::new()defaults toInMemoryAuditSink, and spec/test/demo helpers may intentionally use explicit in-memory audit seams for side-effect-free reporting.NoopAuditSinkremains reserved for callers that explicitly opt intonew_without_audit(...)or wire a noop sink themselves. - Pack registration is idempotent-safe β duplicate pack IDs return
DuplicatePackerror, never silently overwrite. - Generation-based revocation is monotonic β the revocation threshold only increases, never decreases.
- TaskState transitions are irreversible from terminal states β
CompletedandFaultedstates cannot transition.
- Kernel context is bootstrapped at startup β the base CLI loop and shipped service-channel runtimes create
KernelContextbefore processing messages. - Memory persistence failures are surfaced β
persist_turnerrors propagate to the caller, never silently swallowed. - Provider errors have two modes β
Propagate(return error) orInlineMessage(synthetic reply). Behavior is explicit per operator or channel surface.
- Kernel crate: property tests (proptest) for capability boundary invariants
- All crates: deterministic tests (no time-dependent flakes)
- Multi-threaded tests use
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]