Skip to content

feat(selfserve): scope-aware config/identity paths, user settings merge, version fallback#276

Open
michiosw wants to merge 1 commit into
mainfrom
selfserve-paths-foundations
Open

feat(selfserve): scope-aware config/identity paths, user settings merge, version fallback#276
michiosw wants to merge 1 commit into
mainfrom
selfserve-paths-foundations

Conversation

@michiosw

@michiosw michiosw commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

What & why

Foundations for self-serve on the CLI side (ENG-442) — the changes that let one binary serve both an MDM-managed Mac and a self-serve one, with enterprise behaviour byte-identical. No user-facing command yet; that's #277.

  • Scope-aware config + identity paths. managedconfig.ResolvePath() resolves env override > system /Library (if present) > user ~/Library, and Load() records the Scope. System (MDM) config always wins; an invalid system file is an error, never a silent fall-through to user scope. Installation identity follows the same scope so a user config reads a user installation.json, never the MDM one.
  • ~/.claude/settings.json hooks merge (internal/claudemanaged/usersettings.go): remove-ours-then-append-canonical per event, operating on map[string]any so all foreign content survives. Ownership is the shared IsManagedHookCommand predicate (disjoint from Guard hooks). Writes preserve the existing file mode, create new files 0600, and back up first.
  • cli-<version> deployment-version fallback reported to the ledger when no MDM package marker exists (self-serve brew installs).

How to review / test — pure Go, nothing to install

go build ./... && go vet ./... && go test ./...

The behaviour is fully covered by unit tests — no real filesystem-of-record, keychain, or daemon needed:

  • managedconfig/config_test.go: the env/system/user resolution matrix incl. invalid-system-no-fall-through.
  • installation/state_test.go: scope-derived identity path.
  • claudemanaged/usersettings_test.go: foreign-content preservation, stale-path replacement, Guard hooks left untouched, idempotency, malformed JSON, mode preservation.

Risk

The enterprise default path is unchanged: with no env override and a system /Library config present, resolution and the installation path are identical to pre-self-serve. Only the new user-scope branch is added.

Part of the ENG-442 kontext-cli stack: #276 -> #277 -> #278.

michiosw commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

@greptile-apps

greptile-apps Bot commented Jun 13, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds self-serve managed-observe foundations while keeping the existing enterprise path intact. It changes:

  • Adds scope-aware managed config resolution across env, system, and user locations.
  • Ties installation identity storage to the resolved config scope.
  • Adds user-level Claude settings merge, backup, and removal helpers for managed hooks.
  • Reports a CLI-version fallback when no MDM deployment marker exists.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Reviews (3): Last reviewed commit: "feat(selfserve): scope-aware config/iden..." | Re-trigger Greptile

Comment thread internal/claudemanaged/usersettings.go
Comment thread internal/claudemanaged/usersettings.go Outdated
Comment thread internal/claudemanaged/usersettings.go
@michiosw michiosw force-pushed the selfserve-paths-foundations branch from 1ba7ba8 to 55ae7c5 Compare June 13, 2026 09:34

Copy link
Copy Markdown
Contributor Author

@greptileai

Comment thread internal/claudemanaged/usersettings.go Outdated
@michiosw michiosw requested a review from hasandemirkiran June 13, 2026 11:21
…ge, version fallback

Foundations for self-serve (non-MDM) managed observe:

- managedconfig.ResolvePath: env override > system /Library (MDM always
  wins, including on stat errors — never silently shadowed) > user
  ~/Library path written by the upcoming 'kontext setup'
- installation.UserPath + daemon ties identity scope to config scope;
  enterprise defaults byte-identical
- claudemanaged user-settings merge: idempotent install/remove of the five
  managed hooks in ~/.claude/settings.json, preserving all foreign content
  and file permissions; disjoint from Guard hooks
- deployment version fallback: MDM marker wins, brew installs report
  cli-<version>

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@michiosw michiosw force-pushed the selfserve-paths-foundations branch from 55ae7c5 to 8d585d0 Compare June 13, 2026 11:30
@michiosw

Copy link
Copy Markdown
Contributor Author

@greptileai

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.

1 participant