| title | Contribution Golden Path |
|---|
Use this guide to choose the smallest reliable development loop for a pull request. It does not replace the area-specific architecture and security documents linked below; it connects each common change type to its contracts, focused checks, and CI coverage.
- Choose the base before editing. Find the highest active
release/v*branch and branch from its tip. Target that branch, notmain. If a release freeze is active, do not target the frozen branch; use the next active cycle described in Branching & Release Model. - Name the contracts. Identify every catalog, schema, generated artifact, public API, or user interface that the change affects. The table below gives the minimum starting set.
- Write or update focused tests. Production changes in
src/,open-sse/,electron/, orbin/require an automated test in the same PR. Run the smallest test files that prove the behavior, then the listed focused gates. - Let CI run the broad matrix. The complete unit shards, Vitest, coverage ratchet, and production build run on the PR. Run a broad suite locally only when a focused failure points to wider impact or when the change spans several subsystems.
- Reconcile before review. Fetch the active base, inspect its new commits and your diff against it, then rebase or merge the base according to the contributor workflow. Resolve generated-file and catalog conflicts from their source, regenerate them, rerun the focused loop, and confirm the PR still targets the active release branch.
- Record evidence. In the PR template, list the commands run, every test file added or changed, migrations or feature flags, and any CI-only validation still pending.
Commands below are minimum focused checks, not permission to skip a test that directly covers the behavior you changed.
Contracts
- Provider definition in
src/shared/constants/providers/and its composition insrc/shared/constants/providers.ts. - Models and capabilities in
open-sse/config/providerRegistry.tsor its extracted registry files. - Executor/translator selection, OAuth or API-key configuration, dashboard assets, and generated provider reference when applicable.
- Public credentials must use
resolvePublicCred(); error responses must use the shared sanitized error helpers. Seedocs/security/PUBLIC_CREDS.md(git; not compiled into/docs) and Error Sanitization.
Focused loop
npm run check:provider-consistency
npm run check:provider-assets
node --import tsx/esm --test tests/unit/provider-translate-path-golden.test.ts
node --import tsx/esm --test tests/unit/<provider-or-executor>.test.ts
npm run gen:provider-reference # when the catalog changes; commit the generated diff
npm run lintAlso test every affected request family: chat, Responses, images, embeddings, audio, or video. Review generated catalog and golden diffs as contract changes; do not accept them blindly.
Contracts
- Public strategy values and UI metadata in
src/shared/constants/routingStrategies.ts. - Dispatch and ordering under
open-sse/services/combo.tsandopen-sse/services/combo/. - Combo schemas, persistence, resilience state, model capabilities, and API/UI controls.
- Auto-Combo Engine and resilience documentation when behavior changes.
Focused loop
node --import tsx/esm --test tests/unit/combo-<behavior>.test.ts
npm run test:combo:matrix # strategy or dispatch changes
npm run check:known-symbols # strategy registration changes
npm run lintUse deterministic mocked-upstream tests locally. Live combo smokes require credentials and are manual, not CI substitutes.
Contracts
- Next.js route/page and shared component boundaries under
src/app/andsrc/shared/components/. - API response shapes, loading/empty/error states, keyboard and screen-reader behavior, responsive layout, theming, and locale expansion.
- English UI source strings in
src/i18n/messages/en.json; do not hard-code new user-facing copy.
Focused loop
node --import tsx --test tests/unit/dashboard/<feature>.test.ts
npx vitest run --config vitest.config.ts tests/unit/ui/<component>.test.tsx
npm run check:dashboard-typecheck
npm run lintRun the app for interaction or visual changes and check both narrow and wide viewports. CI runs the production build and broader suites; visual behavior still needs a focused component, Playwright, or documented manual check appropriate to the change.
Contracts
src/i18n/messages/en.jsonis the UI source;config/i18n.jsonis the locale source.- CLI catalogs live separately under
bin/cli/locales/. - Preserve ICU placeholders and tags exactly. Do not translate product/provider/model names,
protocol and header names, commands, code/JSON identifiers, URLs, environment variables, or
protected terms such as
OmniRoute,OAuth,MCP, andA2A. The current source list isscripts/i18n/glossary/protected-terms.json.
Focused loop
npm run i18n:sync-ui:dry
npm run i18n:check-ui-coverage
npm run i18n:check-value-drift
npm run i18n:check-glossary
npm run check:cli-i18n # when CLI strings/catalogs change
npm run lintThis is guidance for the existing system, not an invitation to expand its tooling or key model. Keep i18n patches surgical while the replacement system is being designed. Do not run translation commands that call external services unless the task explicitly requires generated translations and you have reviewed the resulting diff.
Contracts
- Public commands and flags in
bin/cli/, generated API commands, exit codes, stdout/stderr and JSON output shapes, config/environment behavior, and packaged files. - CLI user-facing strings must use the CLI i18n layer and keep
en/pt-BRcatalogs aligned. - Preserve Node as the supported runtime and the published binary contract.
Focused loop
node --import tsx/esm --test tests/unit/cli/<command>.test.ts
npm run check:cli-i18n
npm run build:cli # generated/bundled CLI changes
npm run check:pack-policy # package-surface changes
npm run lintUse the exact command in a temporary data directory when behavior depends on parsing, files, or exit status. CI performs the broader package artifact and ecosystem checks.
Contracts
- Domain modules under
src/lib/db/; import specific modules directly (the oldlocalDb.tsre-export layer was removed). - Numbered, idempotent SQL migrations under
src/lib/db/migrations/, transaction safety, upgrade behavior, indexes, and every caller affected by the schema. - Routes and handlers never issue raw SQL directly.
Focused loop
npm run check:migration-numbering
npm run check:db-rules
node --import tsx/esm --test tests/unit/db/<domain>.test.ts
node --import tsx/esm --test tests/unit/db/migration-<number>.test.ts
npm run lintTest both a fresh database and upgrade from the prior schema when adding a migration. Database tests
must close handles and call resetDbInstance() during cleanup. Run npm run test:bun:db only when
the best-effort Bun adapter path changes; Node remains authoritative.
Contracts
- Root and workspace manifests/lockfile,
scripts/build/, Next.js standalone assembly,dist/package contents, Electron platform metadata, CI workflows, and deployment sentinels. - Supported Node ranges and the allow-listed Bun use in
CLAUDE.mdmust remain intact. - Build artifacts stay untracked; dependency, license, workflow, and package policies apply.
Focused loop
node --import tsx/esm --test tests/unit/build/<behavior>.test.ts
npm run check:build-scope
npm run check:lockfile # dependency or lockfile changes
npm run check:pack-policy # published package surface changes
npm run lintUse npm run build locally only when the change affects compilation, standalone assembly, assets,
or runtime bundling. Use npm run build:release only for release/deploy validation. CI's build is
the final cross-platform signal; platform-specific Electron changes need the matching focused build
or smoke evidence.
Two scripts/dev/ helpers encode the local loop on a devbox where other sessions are active:
scripts/dev/typecheck-touched.sh --base release/vX.Y.Z # files from merge-base(HEAD, base)..HEAD
scripts/dev/typecheck-touched.sh src/a.ts tests/unit/b.test.ts # exactly these files
scripts/dev/new-worktree.sh fix/1234-slug release/vX.Y.Z # isolated worktree, safe in paralleltypecheck-touched.shtypechecks only the touched.ts/.tsxfiles through a temporarytsconfig.touched.tmp.json(extends ./tsconfig.json,types: ["node"],noEmit,incremental: false) under a 6 GB heap, so it replaces the project-widetsc -p tsconfig.jsonthat OOMs a loaded machine. It prints the errors in touched files plus one summary line and exits1for errors in touched files,2when the only errors are in imported files or tsc died without diagnostics (read the log it names under_artifacts/typecheck-touched/),0when clean. The temp tsconfig is always removed; never commit one.new-worktree.shserialises concurrent runs on<git-common-dir>/omniroute-new-worktree.lock(waits up to 600 s by default, with a visible message; the script header documents the override) and rolls back the branch it created whengit worktree addfails before the worktree exists, so a retry needs no manualgit branch -D. The hard-linkednode_modulesand.husky/_copy are unchanged.
Source tests cannot prove that the packaged artifact boots: packaging lists, pruned dependencies,
and native binaries only fail once the tarball is installed and started. npm run dev:candidate
(scripts/dev/candidate.mjs) is the local side of the build-once / validate / promote flow from
RFC #8084: it builds one candidate, validates that exact artifact, promotes it with directory
renames, and rolls it back when the promoted slot fails its health check.
npm run dev:candidate -- run --dry-run --json # print the plan, change nothing
npm run dev:candidate -- run # build + validate + promote, auto-rollback
npm run dev:candidate -- build # npm pack + install into _artifacts/candidate/<id>/
npm run dev:candidate -- validate --id <id> # boot on a free port, /api/health + /v1/models
npm run dev:candidate -- promote --id <id> # <id> → current, current → previous
npm run dev:candidate -- rollback # swap current and previous
npm run dev:candidate -- run --from-tarball <file.tgz> # reuse a tarball built elsewhere (CI)- Build once.
buildpacks the current tree (it needsdist/server.js, so runnpm run build:releasefirst) or copies--from-tarball, then installs the tarball into an isolated npm prefix, because the tarball carries nonode_modules. The id is the shortHEADsha (-dirtywhen the tree has local changes) ortgz-<sha256>for a tarball. A clean id that is already built is reused instead of rebuilt; pass--forceto rebuild it. - Validate the package, not the source.
validatestarts the installed CLI (serve --port <free port>) with a freshDATA_DIR=<candidate>/data, fake secrets, and the operator'sOMNIROUTE_API_KEY,STORAGE_ENCRYPTION_KEYandINITIAL_PASSWORDremoved from the environment, so it checks the keyless loopback posture of a fresh install. It waits forGET /api/healthto return 200, requiresGET /v1/modelsto return 200, stops the process group, and records the verdict invalidation.jsontogether with the tarball hash. - Promote the same artifact.
promoterefuses a candidate without a passing validation for its current tarball hash. The default active slot is_artifacts/candidate/current;--target <dir>selects another directory on the same filesystem, and its previous slot is<dir>.previous. Each rename is atomic, and a failure partway through reverses the renames that already ran. - Roll back.
runvalidates the promoted slot again and swapscurrentandpreviousback when that check fails. A candidate that fails the first validation is never promoted.
Everything is written under the gitignored _artifacts/candidate/; an existing OmniRoute
installation and its data directory are never touched. The promoted CLI is
_artifacts/candidate/current/prefix/bin/omniroute; start it with your own DATA_DIR when you use
it. Exit codes: 0 success, 1 failed validation or promotion, 2 usage error or missing build.
| Run locally for each patch | CI supplies the broad signal |
|---|---|
| Direct behavior tests and category gates above | Sharded full unit suite and serial tests |
npm run lint |
Vitest suites and coverage/quality ratchets |
| Typecheck or build only when the affected contract calls for it | Production build, security, docs, dependency, and PR-policy gates |
| Manual interaction/live checks only when automation cannot prove the behavior | Cross-job integration and platform checks configured by workflow |
A green focused loop is evidence about the changed contract, not proof that unrelated CI checks will pass. Conversely, do not make every local edit wait for the full repository matrix.
Before requesting review:
- Confirm the PR base is still the highest active
release/v*branch. - Fetch that base and review commits that landed since you branched.
- Review
git diff <active-base>...HEADfor accidental or generated churn. - Resolve catalog and generated-document conflicts by updating the source and regenerating output.
- Rerun every focused test/gate listed in the PR description after reconciliation.
- Never weaken assertions or drop required tests merely to match a moved base.
For release-freeze and retargeting rules, use Branching & Release Model. For the complete CI inventory, use Quality Gates Reference.