Skip to content

feat(cli): make kontext start local-first#140

Merged
tumberger merged 1 commit into
mainfrom
05-16-feat_cli_make_kontext_start_local-first
May 17, 2026
Merged

feat(cli): make kontext start local-first#140
tumberger merged 1 commit into
mainfrom
05-16-feat_cli_make_kontext_start_local-first

Conversation

@tumberger
Copy link
Copy Markdown
Contributor

@tumberger tumberger commented May 16, 2026

Summary

  • Makes kontext start launch the local runtime by default, with local dashboard and wrapper-owned hook socket setup.
  • Adds a reusable runtimehost boundary for local runtime hosting: DB/store setup, embedded model activation, session dir/socket lifecycle, dashboard binding, and session close.
  • Keeps hosted sessions explicit through kontext start --managed, and prevents local KONTEXT_MODE from leaking into managed hook behavior.

Reviewer follow-up

  • Dashboard binds are loopback-only by default for the new local start path.
  • Local session directories use full safe session IDs with collision checks.
  • The default risk model is embedded, so release binaries do not depend on the caller's current working directory.
  • Startup output reports the resolved observe/enforce mode.
  • os.Executable() failures now stop both local and managed settings generation.

Verification

  • go test ./cmd/kontext ./internal/run ./internal/runtimehost ./internal/guard/modelsnapshot
  • go test ./...
  • go test -race ./...
  • go vet ./...
  • buf generate if protobuf or generated code changed

Release notes

  • conventional commit title matches semver intent

Copy link
Copy Markdown
Contributor Author

tumberger commented May 16, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@tumberger tumberger marked this pull request as ready for review May 16, 2026 09:14
@tumberger tumberger requested a review from michiosw as a code owner May 16, 2026 09:14
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 16, 2026

Greptile Summary

This PR makes kontext start run a local runtime by default. It changes:

  • Adds --managed for hosted sessions.
  • Introduces runtimehost for local DB, model, socket, session, and dashboard lifecycle.
  • Generates local hook settings with explicit socket and mode values.
  • Embeds the default guard model for release builds.
  • Tightens local model snapshot and runtime file permissions.

Confidence Score: 4/5

This is close, but the local shutdown path should be fixed before merging.

  • The new local runtime can close a session while async hook ingestion is still active.

  • That can reopen the session row or drop final telemetry after the agent exits.

  • The main local-first flow otherwise has the expected loopback dashboard, embedded model, and explicit mode handling.

  • internal/runtimehost/host.go

  • internal/localruntime/service.go

Important Files Changed

Filename Overview
internal/runtimehost/host.go Adds the local runtime host lifecycle; shutdown ordering can race async hook ingestion.
internal/run/local.go Adds the default local start flow that launches runtimehost, writes hook settings, and starts the agent.
internal/run/hooks.go Adds local hook settings with explicit --socket and --mode command arguments.

Reviews (3): Last reviewed commit: "feat(cli): make kontext start local-firs..." | Re-trigger Greptile

Comment thread internal/run/local.go Outdated
Comment thread internal/run/local.go Outdated
Comment thread internal/run/local.go Outdated
Comment thread internal/run/local.go Outdated
Comment thread internal/run/local.go Outdated
@tumberger tumberger marked this pull request as draft May 16, 2026 10:01
@tumberger tumberger force-pushed the 05-16-feat_cli_make_kontext_start_local-first branch from e7fb567 to 248c427 Compare May 16, 2026 10:29
@tumberger
Copy link
Copy Markdown
Contributor Author

tumberger commented May 16, 2026

Architecture note for this PR:

This PR intentionally makes kontext start the local-first sidecar entrypoint: it starts the local runtime for one agent session, launches Claude with temporary hook settings, and shuts the runtime down when the agent exits. kontext start --managed remains the explicit hosted/team path.

The key architecture change is the new runtimehost boundary. runtimecore owns hook/session/policy semantics, localruntime owns the Unix socket protocol, and runtimehost owns process-host concerns like model activation, SQLite/store setup, socket/session directory lifecycle, dashboard startup, and cleanup.

That extra abstraction is here so kontext start does not rebuild a one-off local daemon inside internal/run, and so future host modes can share the same model/store/server/socket/dashboard wiring. This does not mean the daemon topology goes away. Issue #104 explicitly separated wrapper-owned sidecar mode from daemon-observed mode: kontext start should launch the agent, while a daemon mode should let already-running or normally-launched Claude sessions connect through persistent hooks.

Follow-up cleanup I would scope separately:

  • Add a neutral daemon surface, likely kontext daemon, backed by runtimehost in daemon-observed mode with a stable socket and dashboard.
  • Make kontext guard start a compatibility/deprecated alias over that daemon path, instead of keeping its parallel daemon assembly.
  • Remove Guard from user-visible product copy and dashboard branding once kontext start is the primary local sidecar path and kontext daemon is the neutral observed-session path.
  • Decide whether persistent hook install/uninstall stays as an advanced feature; if it does, move it to a neutral command surface and have it call the canonical kontext hook --agent claude path.
  • Only after the runtime paths are unified, consider mechanical package renames out of internal/guard for risk, store, model snapshot, dashboard, and Markov components.

@tumberger tumberger marked this pull request as ready for review May 16, 2026 12:35
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@tumberger
Copy link
Copy Markdown
Contributor Author

@greptileai

Comment thread internal/runtimehost/host.go Outdated
@tumberger tumberger force-pushed the 05-16-feat_cli_make_kontext_start_local-first branch from 248c427 to 43ae9c9 Compare May 16, 2026 13:44
michiosw
michiosw previously approved these changes May 17, 2026
@tumberger tumberger force-pushed the 05-16-feat_cli_make_kontext_start_local-first branch from 43ae9c9 to 5090a85 Compare May 17, 2026 09:08
@tumberger tumberger force-pushed the feat/eng-331-readme-banner branch from a7bd779 to 26d41da Compare May 17, 2026 09:08
@tumberger tumberger force-pushed the 05-16-feat_cli_make_kontext_start_local-first branch 2 times, most recently from f6914b4 to 4caf6d3 Compare May 17, 2026 10:02
@tumberger tumberger force-pushed the feat/eng-331-readme-banner branch from 26d41da to b26c752 Compare May 17, 2026 10:02
@tumberger tumberger force-pushed the 05-16-feat_cli_make_kontext_start_local-first branch from 4caf6d3 to 3a62281 Compare May 17, 2026 10:06
@tumberger tumberger force-pushed the feat/eng-331-readme-banner branch from b26c752 to 6941687 Compare May 17, 2026 10:06
@tumberger tumberger force-pushed the 05-16-feat_cli_make_kontext_start_local-first branch from 3a62281 to b4606cd Compare May 17, 2026 10:07
@tumberger tumberger force-pushed the feat/eng-331-readme-banner branch from 6941687 to 54656a7 Compare May 17, 2026 10:07
@tumberger tumberger force-pushed the 05-16-feat_cli_make_kontext_start_local-first branch from b4606cd to 6aadd7e Compare May 17, 2026 10:11
@tumberger tumberger force-pushed the feat/eng-331-readme-banner branch from 54656a7 to 6ff29d2 Compare May 17, 2026 10:11
@tumberger tumberger force-pushed the 05-16-feat_cli_make_kontext_start_local-first branch from 6aadd7e to 04b895b Compare May 17, 2026 10:18
@tumberger tumberger force-pushed the feat/eng-331-readme-banner branch 2 times, most recently from 6dd7d64 to ea7d78e Compare May 17, 2026 10:19
@tumberger tumberger force-pushed the 05-16-feat_cli_make_kontext_start_local-first branch 2 times, most recently from d72c0c8 to f793aca Compare May 17, 2026 10:21
@tumberger tumberger force-pushed the feat/eng-331-readme-banner branch from ea7d78e to a4125e2 Compare May 17, 2026 10:21
@tumberger tumberger force-pushed the 05-16-feat_cli_make_kontext_start_local-first branch from f793aca to 7568187 Compare May 17, 2026 10:22
@tumberger tumberger force-pushed the feat/eng-331-readme-banner branch from a4125e2 to 3c105cb Compare May 17, 2026 10:22
Copy link
Copy Markdown
Contributor Author

tumberger commented May 17, 2026

Merge activity

  • May 17, 10:36 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 17, 10:37 AM UTC: Graphite rebased this pull request as part of a merge.
  • May 17, 10:39 AM UTC: @tumberger merged this pull request with Graphite.

@tumberger tumberger changed the base branch from feat/eng-331-readme-banner to graphite-base/140 May 17, 2026 10:36
@tumberger tumberger changed the base branch from graphite-base/140 to main May 17, 2026 10:36
@tumberger tumberger dismissed michiosw’s stale review May 17, 2026 10:36

The base branch was changed.

@tumberger tumberger force-pushed the 05-16-feat_cli_make_kontext_start_local-first branch from 7568187 to 9886b8d Compare May 17, 2026 10:37
@tumberger tumberger merged commit 02a34bf into main May 17, 2026
4 checks passed
@tumberger tumberger deleted the 05-16-feat_cli_make_kontext_start_local-first branch May 17, 2026 10:39
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