13 KiB
D601 Dev Environment
This document is the authoritative source for the persistent unidesk-dev environment, the public dev frontend port, deploy apply --env dev, and the Rust backend-core build boundary. Release-line and dev-lane governance is owned by docs/reference/release-governance.md and GitHub issue #6. If the same dev-environment rule would need edits in AGENTS.md, docs/reference/cli.md, docs/reference/deploy.md, docs/reference/ci.md, docs/reference/deployment.md, docs/reference/e2e.md or TEST.md, keep the detailed rule here and leave only a short cross-reference elsewhere.
Goal
The dev environment lets users experience the next UniDesk version without interrupting production:
- Production stays on the normal public frontend at
http://74.48.78.17:18081/. - Dev is exposed through a separate main-server public port at
http://74.48.78.17:18083/. - Dev backend/frontend workloads run in D601 native k3s namespace
unidesk-dev, not in the main-server Compose stack. - Dev backend-core build and frontend artifact rollout use pushed Git commits from
origin/master:deploy.json#environments.dev, not dirty local worktrees. - Rust backend-core check/build must run on D601 through CI or dev deploy; the master server must not compile Rust for this iteration path.
Public Dev Frontend Port
The main server owns one extra public entrypoint for dev UI:
browser -> main-server:18083 -> dev-frontend-proxy -> prod backend-core microservice proxy -> k3sctl-adapter -> D601 k3s Service frontend-dev -> frontend-dev -> backend-core-dev
dev-frontend-proxy is an nginx sidecar in the main-server Compose project. It proxies requests to backend-core:8080/api/microservices/k3sctl-adapter/proxy/api/services/frontend-dev/proxy..., so D601 does not expose a new public port and the dev UI still crosses the existing UniDesk/k3sctl-adapter control boundary. The proxy is intentionally thin: it does not build frontend assets, does not talk to D601 directly, and does not contain DevOps logic.
frontend-dev and backend-core-dev are registered with k3sctl-adapter through the managed-service catalog src/components/microservices/k3sctl-adapter/k3s/dev/unidesk-dev-core.k3s.json. The public dev port must use that cataloged Kubernetes API service-proxy path; it must not add a direct D601 public port, NodePort, or backend-core catalog entry for arbitrary k3s services.
The dev public port is configured in config.json as network.devFrontend.port=18083, surfaced by server status as urls.devFrontend, and managed by server rebuild dev-frontend-proxy. The proxy health depends on frontend-dev; it can be unhealthy until the D601 dev frontend has been deployed.
The unrestricted public network entries are therefore production frontend, dev frontend, and provider ingress. backend-core REST, PostgreSQL, user-service backend ports, k3s Services, NodePorts and D601 host ports remain private or explicitly restricted.
Dev and production frontend authentication must use the same config.json.auth username, password, session secret and session TTL. The public dev and production entrypoints share the same IP/host with different ports, so the unidesk_session cookie is host-scoped rather than port-scoped. deploy apply --env dev --service frontend must sync unidesk-dev-runtime-secrets and unidesk-dev-runtime-config from the main-server config before rolling out frontend-dev; dev manifests may contain placeholders but must not establish a separate dev login identity.
Desired State
deploy.json remains the only version intent file. Dev entries live under environments.dev and are read from origin/master:deploy.json, never from a dirty local file, when using --env dev or ci run-dev-e2e.
The target release-governance model is to split stable maintenance validation from high-risk master integration, for example with explicit lanes such as dev-v1 and dev-master. That split is not active until deploy.json, deploy commands, CI, frontend labels and diagnostics support it explicitly. Until then, the documented environments.dev behavior remains the active contract and must not be emulated through local manifest edits or hidden branch conventions.
During a release/v1 stabilization window, this same implemented environments.dev lane is temporarily reserved for v1 validation. Use pushed commits and explicit deploy.json pins to validate v1 fixes; do not add a parallel dev-v1/dev-master schema in the middle of the stabilization window unless that split is the blocker for v1. The detailed phase rule lives in docs/reference/release-governance.md.
The persistent dev rollout currently supports:
backend-coreas a D601 target-side build.frontend,decision-center,mdtodo,claudeqqandcode-queueas D601 registry artifact consumers inunidesk-dev.baidu-netdiskas the main-server direct user-service artifact validation sample.
deploy apply --env dev --service baidu-netdisk consumes the D601 registry artifact and validates the main-server Compose service; it is not a persistent D601 k3s dev workload. deploy apply --env dev --service code-queue is intentionally dev-only and may mutate only unidesk-dev Code Queue scheduler/read/write/provider-egress-proxy objects. deploy apply --env prod --service code-queue must remain unsupported. The environments.dev.ci declaration and short launcher runner are owned by docs/reference/dev-ci-runner.md.
Rust Backend-Core Boundary
backend-core is implemented as a Rust service for the dev path. The master server may inspect files, run TypeScript CLI checks, render Compose config, dispatch jobs and proxy traffic, but it must not run Rust compilation for backend-core iteration.
Allowed on the master server:
bun scripts/cli.ts check --files --scripts-typecheck --compose --logsbun scripts/cli.ts check --helpbun scripts/cli.ts deploy plan --env dev --service backend-corebun scripts/cli.ts deploy apply --env dev --service backend-corebun scripts/cli.ts ci run --revision <commit>bun scripts/cli.ts ci run-dev-e2e --wait-ms <ms>
Not allowed on the master server for this path:
cargo check,cargo build,cargo testorrustfmtagainst backend-core.bun scripts/cli.ts check --rustwithout the D601 CI guard.bun scripts/cli.ts server rebuild backend-coreas a way to iterate Rust backend-core, because it would build the Rust image in the main-server Docker daemon.- Ad-hoc
docker buildofsrc/components/backend-core/Dockerfileon the master server.
Rust checking is enabled only when the process is already running inside the D601 CI/dev execution boundary: UNIDESK_D601_RUST_CHECK=1 bun scripts/cli.ts check --full --rust. check --rust deliberately fails outside that guard with an explicit explanation instead of silently compiling on the wrong host.
Dev Deploy Path
deploy apply --env dev --service backend-core|frontend|decision-center|mdtodo|claudeqq|code-queue is the controlled persistent dev rollout path for D601 dev workloads. The controller runs on the master server, but the heavy work runs on D601. backend-core still uses the constrained dev target-side build path; the other listed services consume CI-published commit-pinned artifacts from the D601 registry.
- Fetch
origin/master:deploy.json#environments.devand resolve the requested service commit to a full SHA. - Dispatch to D601 through the existing provider-gateway/Host SSH maintenance capability.
- On D601, fetch/export the requested Git commit through the node-local provider-gateway egress proxy
http://127.0.0.1:18789. - For backend-core, use the target-side commit as the source for Dockerfile, build context and dev k3s manifest, then build the service image on D601 Docker.
- For artifact consumers, require the existing registry image
127.0.0.1:5000/unidesk/<service-id>:<commit>produced byci publish-user-service --service <service-id>; do not build that service source in the dev target. - Import the backend-core build output or registry artifact into native k3s containerd at
/run/k3s/containerd/containerd.sock. - Apply only the selected
unidesk-devService/Deployment objects from the dev manifest. - For
frontend, sync auth/session settings from main-serverconfig.json.authinto the dev runtime Secret/ConfigMap before rollout. - Stamp the Deployment with
UNIDESK_DEPLOY_*env andunidesk.ai/deploy-*annotations. - Verify health through the Kubernetes API service proxy and require the live commit to match the requested commit.
The dev path is not a fallback system. If GitHub fetch, provider-gateway egress, Docker build for backend-core, artifact lookup, native k3s, containerd import, kubectl apply or live health verification fails, the job fails with logs. It must not fall back to building artifact-consumer source on the dev target, building on the master server, using a dirty worktree, direct D601 public ports, NodePort, hostPort, provider-gateway business HTTP, or another deployment command. k3s-managed health verification must use the Kubernetes API service proxy.
DevOps Hygiene
The persistent dev environment follows the shared Git-backed deployment hygiene rules in docs/reference/devops-hygiene.md. In particular, D601 runtime edits, dirty-worktree builds, copied scripts/images/source, direct D601 ports, NodePorts and manual smoke checks without live commit agreement must not become deployment truth.
Standard Workflow
Use this sequence for backend-core Rust and frontend dev work:
- Develop in the current
masterworktree and keep unrelated parallel changes separated withgit status/git diff. - Run local non-Rust checks on the master server, for example
bun scripts/cli.ts check --files --scripts-typecheck --compose --logs. - Commit and push the code to
origin master;deploy apply --env devcannot deploy unpushed local changes. - Update
deploy.jsonenvironments.dev.servicessobackend-coreandfrontendpoint at the pushed commit, then commit and push that manifest update. - For artifact-consumer changes, publish the artifact first:
bun scripts/cli.ts ci publish-user-service --service <frontend|decision-center|mdtodo|claudeqq|code-queue> --commit <full-sha> --wait-ms 1200000. - Run
bun scripts/cli.ts deploy apply --env dev --service backend-coreand observe the returned job withbun scripts/cli.ts job status <jobId> --tail-bytes 30000. - Run
bun scripts/cli.ts deploy apply --env dev --service <frontend|decision-center|mdtodo|claudeqq|code-queue>and observe the job the same way; this must consume the registry artifact and verify live deploy metadata through the service health path. - If the dev service catalog changes, deploy the pushed
k3sctl-adaptercommit through the controlled local manifest exception, then verify/api/control-planelistsk3s/dev/unidesk-dev-core.k3s.json. - Rebuild or verify
dev-frontend-proxyon the main server withbun scripts/cli.ts server rebuild dev-frontend-proxywhen the proxy config or port changes. - Manually test
http://74.48.78.17:18083/and the dev health endpoints. - Run D601 CI for the commit and the dev smoke runner:
bun scripts/cli.ts ci run --revision <commit> --wait-ms <ms>andbun scripts/cli.ts ci run-dev-e2e --wait-ms <ms>. When Code Queue behavior changes, update thecode-queueentry inenvironments.dev.servicesto the pushed commit before running dev artifact validation or the temporary dev smoke.
Validation Commands
Useful read-only or bounded validation commands:
bun scripts/cli.ts server status
bun scripts/cli.ts deploy plan --env dev
bun scripts/cli.ts deploy plan --env dev --service backend-core
bun scripts/cli.ts dev-env validate --manifest src/components/microservices/k3sctl-adapter/k3s/dev/unidesk-dev-core.k8s.yaml
bun scripts/cli.ts dev-env validate --manifest src/components/microservices/k3sctl-adapter/k3s/dev/unidesk-dev-mdtodo.k8s.yaml
bun scripts/cli.ts dev-env validate --manifest src/components/microservices/k3sctl-adapter/k3s/dev/unidesk-dev-claudeqq.k8s.yaml
bun scripts/cli.ts dev-env validate --manifest src/components/microservices/k3sctl-adapter/k3s/dev/unidesk-dev-code-queue.k8s.yaml
bun scripts/cli.ts ci run-dev-e2e --wait-ms 600000
bun scripts/cli.ts microservice proxy k3sctl-adapter /api/services/backend-core-dev/proxy/health --raw --full
bun scripts/cli.ts microservice proxy k3sctl-adapter /api/services/frontend-dev/proxy/health --raw --full
curl -fsS http://127.0.0.1:18083/health
When validating on D601 directly, always use the native kubeconfig explicitly: KUBECONFIG=/etc/rancher/k3s/k3s.yaml. The default kubectl context may point at Docker Desktop and is not valid for UniDesk native k3s verification.