Skip to content

fix: align the local runtime contract - #49

Merged
mohit-nagaraj merged 7 commits into
mainfrom
fix/local-runtime-contract
Aug 20, 2026
Merged

fix: align the local runtime contract#49
mohit-nagaraj merged 7 commits into
mainfrom
fix/local-runtime-contract

Conversation

@mohit-nagaraj

Copy link
Copy Markdown
Member

Summary

  • add a canonical .kubeorch/project.json marker with parent-directory discovery and safe legacy migration behavior
  • allow orchcli init to adopt existing UI/Core checkouts, make initialization idempotent, and improve Windows Docker Desktop handling and service health reporting
  • align generated Compose files, ports, Mongo configuration, pinned images, tests, and documentation with the actual local runtime contract

Validation

  • go test ./...
  • go vet ./...
  • docker compose ... config --quiet for all four shipped Compose modes
  • Linux AMD64 and ARM64 cross-compilation
  • real Windows development smoke from an existing workspace: initialize twice, start MongoDB, run Core/UI from source, and invoke status from nested UI/Core directories
  • Playwright integration smoke: registration 201, login 200, authenticated dashboard/settings requests 200, admin role rendered, and workspace create/list succeeded with no browser console errors

Remaining dependency

The currently published Core and UI v0.0.3 images expose AMD64 manifests only. This PR documents that limitation and pins the available images, but actual macOS ARM64 production/hybrid execution remains blocked on multi-arch component releases. For that reason this PR references rather than closes the runtime issue.

Refs #47

@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d56eadbd-ba7e-41a9-829b-431fee9c465e

📥 Commits

Reviewing files that changed from the base of the PR and between 9f2b3de and 4894868.

📒 Files selected for processing (2)
  • cmd/init.go
  • cmd/runtime_contract_test.go

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The CLI now stores project metadata in local markers, discovers projects from nested directories, accepts existing UI and Core checkouts, and updates command workflows. Compose files use pinned images and revised host/container networking. Documentation and runtime tests cover the new contracts.

Changes

Project configuration and runtime workflows

Layer / File(s) Summary
Project marker resolution
cmd/config.go, cmd/runtime_contract_test.go, docs/CONFIGURATION.md
Project configuration uses versioned .kubeorch/project.json markers with upward discovery, validation, portable paths, legacy registry fallback, and atomic persistence.
Existing checkout initialization
cmd/init.go, cmd/testing.go, README.md, docs/CONFIGURATION.md, tests/unit/cmd_test.go
init accepts existing UI and Core paths, validates checkout markers, installs dependencies, generates configuration, and writes project metadata.
Command project integration
cmd/debug.go, cmd/exec.go, cmd/logs.go, cmd/restart.go, cmd/start.go, cmd/status.go, cmd/stop.go, cmd/utils.go, cmd/root.go
Project-scoped commands resolve configuration before Compose validation. Local-mode detection uses configured paths. Status adds concurrent HTTP health checks. Docker daemon startup uses context-aware polling.
Compose runtime contracts
cmd/docker/*.yml, docker/*.yml, cmd/runtime_contract_test.go
Compose files remove obsolete version fields, pin runtime images, update MongoDB variables and API paths, and run Core on the host in hybrid-core mode.
Runtime documentation and operation examples
README.md, docs/ARCHITECTURE.md, docs/CONCURRENT-OPERATIONS.md, docs/CONFIGURATION.md
Documentation describes project discovery, deployment modes, pinned images, API paths, MongoDB, host-run Core, concurrent operations, and validation commands.

Estimated code review effort: 4 (Complex) | ~60 minutes

Merge Risk: 🟡 Moderate · up to 48948

Initialization can still select the wrong runtime mode or create conflicting nested configuration, while a regression test may pass without validating the intended failure; these bounded issues should be fixed or explicitly accepted before merging.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant InitCommand
  participant ProjectMarker
  participant ProjectCommand
  participant Compose
  participant Core
  participant UI
  User->>InitCommand: provide project or checkout paths
  InitCommand->>ProjectMarker: write .kubeorch/project.json
  User->>ProjectCommand: run a project-scoped command
  ProjectCommand->>ProjectMarker: discover and validate marker
  ProjectCommand->>Compose: validate and start configured services
  UI->>Core: request /v1/api
  ProjectCommand->>Core: perform health check
  ProjectCommand->>UI: perform health check
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 3.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: aligning the local runtime contract.
Description check ✅ Passed The description directly covers the project marker, initialization, runtime, Compose, testing, and documentation changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/local-runtime-contract

Comment @coderabbitai help to get the list of available commands.

Signed-off-by: Mohit Nagaraj <mohitnagaraj20@gmail.com>
@mohit-nagaraj
mohit-nagaraj force-pushed the fix/local-runtime-contract branch from 0c6f2a4 to 5746d42 Compare August 19, 2026 20:43
Comment thread cmd/utils.go Fixed
Comment thread cmd/utils.go Fixed
Comment thread cmd/utils.go Fixed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cmd/init.go (1)

132-152: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Do not require Git for existing-checkout initialization.

checkPrerequisites always checks or installs Git before this function resolves existing paths. With --ui-path or --core-path plus --skip-deps, no later operation needs Git. This documented adoption flow fails on systems without Git and can trigger an unnecessary installation.

Check Git only when cloneUI || cloneCore. Keep Docker Compose validation for every mode.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7f345606-3cc2-4f6e-b85c-a1a21f48f570

📥 Commits

Reviewing files that changed from the base of the PR and between 0cc49da and 5746d42.

📒 Files selected for processing (26)
  • README.md
  • cmd/config.go
  • cmd/debug.go
  • cmd/docker/docker-compose.dev.yml
  • cmd/docker/docker-compose.hybrid-core.yml
  • cmd/docker/docker-compose.hybrid-ui.yml
  • cmd/docker/docker-compose.prod.yml
  • cmd/exec.go
  • cmd/init.go
  • cmd/logs.go
  • cmd/restart.go
  • cmd/root.go
  • cmd/runtime_contract_test.go
  • cmd/start.go
  • cmd/status.go
  • cmd/stop.go
  • cmd/testing.go
  • cmd/utils.go
  • docker/docker-compose.dev.yml
  • docker/docker-compose.hybrid-core.yml
  • docker/docker-compose.hybrid-ui.yml
  • docker/docker-compose.prod.yml
  • docs/ARCHITECTURE.md
  • docs/CONCURRENT-OPERATIONS.md
  • docs/CONFIGURATION.md
  • tests/unit/cmd_test.go

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Comment thread cmd/config.go
Comment thread cmd/config.go
Comment thread cmd/init.go
Comment thread cmd/status.go Outdated
Comment thread cmd/utils.go Outdated
Comment thread docs/ARCHITECTURE.md Outdated
Comment thread docs/CONCURRENT-OPERATIONS.md Outdated
Comment thread README.md
Signed-off-by: Mohit Nagaraj <mohitnagaraj20@gmail.com>
Comment thread cmd/status.go Fixed
Comment thread cmd/status.go Fixed
Signed-off-by: Mohit Nagaraj <mohitnagaraj20@gmail.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cmd/init.go (1)

118-121: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

A plain orchcli init silently downgrades an existing development marker to production mode.

setupProduction calls setProjectConfig(cwd, "", ""), and writeProjectMarker replaces .kubeorch/project.json unconditionally. If a project was initialized with --ui-path/--fork-ui, a later orchcli init without flags rewrites the marker with mode: "production" and empty source paths. The local ui/ and core/ checkouts stay on disk, but start, status, and logs then resolve the production Compose file. The user gets no warning.

Load the existing marker first. If it records source paths, either preserve them or print an explicit message that the project is switching to production mode.

🧹 Nitpick comments (3)
cmd/config.go (1)

223-289: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

Atomic replacement is correct; consider one directory sync for crash durability.

The temporary-file write, Sync, Close, and Rename sequence removes the truncation window that the previous os.WriteFile call created. The rename entry itself is not durable until the parent directory is synced. If crash durability of the marker matters, open the parent directory after os.Rename and call Sync on it, ignoring the "not supported" case on Windows.

cmd/status.go (1)

127-169: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Health checks are correct; consider draining response bodies.

The context-aware requests, the bounded client timeout, and the buffered channel are correct, and no goroutine can leak because every result is read. The bodies are closed without being read, so the underlying connections are not reusable. This does not matter for two one-shot checks. If you want to keep transport hygiene, add io.Copy(io.Discard, response.Body) before the close.

cmd/utils.go (1)

321-338: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Polling is now bounded; make the timeout message generic.

The context deadline plus exec.CommandContext removes the unbounded docker info wait. waitForDockerDaemon is also called from the macOS and Windows paths, so the fixed text "docker desktop did not start within %s" describes only one case. Report the daemon instead, for example "docker daemon did not become ready within %s".


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1af73ecb-b2e0-4b34-a751-c9dcfa4fc3f7

📥 Commits

Reviewing files that changed from the base of the PR and between 5746d42 and 5916e5b.

📒 Files selected for processing (10)
  • README.md
  • cmd/config.go
  • cmd/init.go
  • cmd/root.go
  • cmd/runtime_contract_test.go
  • cmd/start.go
  • cmd/status.go
  • cmd/utils.go
  • docs/ARCHITECTURE.md
  • docs/CONCURRENT-OPERATIONS.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • cmd/root.go
  • cmd/start.go

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread cmd/runtime_contract_test.go
Comment thread docs/CONCURRENT-OPERATIONS.md Outdated
Signed-off-by: Mohit Nagaraj <mohitnagaraj20@gmail.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fa79d431-e335-4837-b851-825d18abb91b

📥 Commits

Reviewing files that changed from the base of the PR and between 8a41f31 and aa36fcf.

📒 Files selected for processing (3)
  • cmd/init.go
  • cmd/runtime_contract_test.go
  • docs/CONCURRENT-OPERATIONS.md

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Comment thread cmd/init.go Outdated
Signed-off-by: Mohit Nagaraj <mohitnagaraj20@gmail.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 03467f05-0c5d-464d-a295-7023c281192e

📥 Commits

Reviewing files that changed from the base of the PR and between aa36fcf and 70a9b55.

📒 Files selected for processing (2)
  • cmd/init.go
  • cmd/runtime_contract_test.go

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Comment thread cmd/runtime_contract_test.go Outdated
Signed-off-by: Mohit Nagaraj <mohitnagaraj20@gmail.com>
@mohit-nagaraj

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8597ab60-b689-4e36-82ea-57c5d6abf9f7

📥 Commits

Reviewing files that changed from the base of the PR and between aa36fcf and 9f2b3de.

📒 Files selected for processing (2)
  • cmd/init.go
  • cmd/runtime_contract_test.go

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread cmd/init.go Outdated
Signed-off-by: Mohit Nagaraj <mohitnagaraj20@gmail.com>
@mohit-nagaraj

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@mohit-nagaraj
mohit-nagaraj merged commit 1e446f5 into main Aug 20, 2026
9 checks passed
@mohit-nagaraj
mohit-nagaraj deleted the fix/local-runtime-contract branch August 20, 2026 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants