This handbook turns the architectural direction in Code quality into the day-to-day practices used to keep mdbase connect understandable as it grows.
A reader should be able to answer four questions from the module layout:
- Which feature owns this behavior?
- Which function or state machine makes the policy decision?
- Which adapter performs the side effect?
- Which test proves the invariant?
Keep entry points and package indexes as composition roots or compatibility
facades. Put behavior in feature modules named for the domain concept. Avoid
new generic utils, common, or services modules; shared code should
represent a stable concept with a narrow contract.
Production modules should usually be 100–600 lines. Crossing the normal range is a design prompt, not an invitation to move unrelated functions into another large file.
Transport adapters validate and translate. Application use cases coordinate. Domain policy decides. Repositories and network clients perform side effects. Dependencies point toward policy, never from policy back to a web framework, database row, browser API, Electron process, or filesystem.
Cross-feature calls use a named public seam. Do not import another feature's repository internals. Rust crate and workspace package cycles are prohibited, as are cycles between relative source modules.
Prefer a sequence that keeps every commit reviewable:
- Characterize existing behavior with a focused test.
- Extract a cohesive module without changing the contract.
- Move policy behind a narrow typed seam.
- Add denial, malformed-input, retry, and recovery coverage as relevant.
- Remove the obsolete path and update the architecture documentation.
Separate behavior changes, migrations, and mechanical movement when doing so makes review or rollback safer. Never split an authorization decision from the transaction or authority that must enforce it.
Reviewers check:
- authorization and privacy at the final authority, including retry paths;
- one owner for each lifecycle and transaction;
- exhaustive tagged states instead of interacting booleans;
- stable structured errors at process and package boundaries;
- cancellation, cleanup, idempotency, and timeout behavior;
- logs that omit secrets, record payloads, and local paths;
- protocol compatibility in both Rust and TypeScript;
- focused regression coverage and the relevant end-to-end journey; and
- documentation for changed user, operator, security, or architectural behavior.
Security-sensitive paths are listed in .github/CODEOWNERS. The current
single-maintainer mapping is deliberately explicit and can be replaced with
team aliases without changing protected paths.
Use the narrowest checks while iterating. Before handoff, run:
pnpm install --frozen-lockfile
pnpm version:check
pnpm check:release-readiness
pnpm audit:dependencies
pnpm check:architecture
cargo fmt --all --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace
pnpm build
pnpm typecheck
pnpm test
pnpm package:auditpnpm test:fast, pnpm test:integration, and pnpm test:system are the
canonical test tiers. pnpm test:all is the exhaustive local entry point;
select individual system suites while iterating rather than repeatedly paying
for unrelated environments.
Run the browser persistence and accessibility suites for browser, portal, or desktop changes. Run the local, relay, sync, provider, and containerized journeys for changes that touch their boundary. See Testing for environment details.
Dependency updates are reviewed weekly and high-severity audit findings fail
CI. Beta releases may carry the explicitly documented external risks in
config/release-readiness.json; a stable release runs the same checker with
--stable and cannot pass until every gate is complete and contains an
evidence reference. On 2026-11-17 the release owner retired the encrypted
backup and restore drill and platform signing and notarization gates as stale
requirements; they were removed from the manifest without being completed.
Update design records and the release-readiness manifest in the same pull request as the decision they record. An empty checkbox is not evidence: reviews, drills, signing verification, and operational controls need durable, dated artifacts.