Skip to content

feat(observe): surface revoked install tokens; doctor managed-observe section#278

Open
michiosw wants to merge 1 commit into
selfserve-setup-commandfrom
selfserve-auth-devx
Open

feat(observe): surface revoked install tokens; doctor managed-observe section#278
michiosw wants to merge 1 commit into
selfserve-setup-commandfrom
selfserve-auth-devx

Conversation

@michiosw

@michiosw michiosw commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

What & why

Revoked-token DevX + kontext doctor, and the final wire-format change (ENG-442). Closes the loop so a self-serve operator whose key was revoked gets an actionable message instead of a silently-dead daemon. Builds on #277.

  • Consecutive-401 detection: managedstream fires OnAuthFailure after 3 straight 401/403s (re-fires periodically), and OnFlushSuccess only after an accepted post. The daemon turns that into a stderr line ("token rejected — run kontext setup with a new token") and a last-auth-error.json breadcrumb next to the guard DB; a later success clears it.
  • kontext doctor managed-observe section: config path + scope (system MDM / user / env), org, installation id, live token-resolve check through the daemon's read path, socket probe, LaunchAgent presence + MDM-coexistence warning, and the breadcrumb (kind-aware: auth vs startup).
  • Batches no longer send organization_id. The install token is the only org binding (server resolves it per request, see #574); managed.json keeps the org id purely as a local label for doctor/setup output. Stream Options/Payload drop the field and tests assert it is absent from the wire.

How to review / test — pure Go

go build ./... && go vet ./... && go test ./... && go test -race ./...
  • managedstream/stream_test.go: the 401 counter + refire, OnFlushSuccess only on accepted post, and assertion that organization_id is absent from the posted payload.
  • managedobserve/autherr_test.go + doctor_test.go: breadcrumb round-trip, corrupt-file tolerance, doctor section rendering.

To see the live revoked-token behaviour, use the branch-built binary from #277 against the local stack, then revoke the key in the dashboard: within a few flushes the daemon logs the actionable message and the breadcrumb appears; kontext doctor shows it; seeding a fresh key clears it on the next accepted flush. (No brew required.)

Risk

The claim removal is forward-safe: old deployed agents keep sending organization_id and the server keeps verifying it (#574); only new agents omit it. Rollout: the kontext API change (#574) must be deployed before a CLI release that omits the claim.

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

michiosw commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

@michiosw michiosw force-pushed the selfserve-auth-devx branch 2 times, most recently from 33c50e3 to e50c9f0 Compare June 11, 2026 13:08
@michiosw michiosw force-pushed the selfserve-setup-command branch 2 times, most recently from 760e845 to d1f8aa7 Compare June 11, 2026 13:19
@michiosw michiosw force-pushed the selfserve-auth-devx branch 3 times, most recently from 29d7991 to 912e0bd Compare June 12, 2026 14:18
@michiosw michiosw force-pushed the selfserve-setup-command branch from d1f8aa7 to 3acdc06 Compare June 12, 2026 14:18
@michiosw michiosw marked this pull request as ready for review June 13, 2026 09:18
@greptile-apps

greptile-apps Bot commented Jun 13, 2026

Copy link
Copy Markdown

Greptile Summary

This PR improves managed-observe diagnostics and updates the hosted ledger wire format. The main changes are:

  • Adds auth and startup breadcrumb files for daemon token failures.
  • Surfaces managed-observe status in kontext doctor.
  • Reports repeated hosted 401/403 responses and clears breadcrumbs after accepted posts.
  • Removes organization_id from managedstream batch payloads.
  • Tightens hosted hook detection in Guard doctor output.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Reviews (2): Last reviewed commit: "feat(observe): surface revoked install t..." | Re-trigger Greptile

Comment thread internal/managedobserve/doctor.go
Comment thread internal/guard/cli/cli.go Outdated
@michiosw michiosw force-pushed the selfserve-auth-devx branch from 912e0bd to ab1ffbb Compare June 13, 2026 09:34
@michiosw michiosw force-pushed the selfserve-setup-command branch from 3acdc06 to 4c34bc7 Compare June 13, 2026 09:34

Copy link
Copy Markdown
Contributor Author

@greptileai

@michiosw michiosw requested a review from hasandemirkiran June 13, 2026 11:21
… section

A revoked/rotated token previously spun silently under launchd. Now:

- managedstream fires OnAuthFailure after 3 consecutive 401/403 flushes
  (re-fires periodically) and OnFlushSuccess on recovery
- the daemon prints an actionable message to stderr (lands in the agent
  log) and drops a last-auth-error.json breadcrumb next to guard.db,
  cleared on the next successful flush
- 'kontext doctor' gains a managed-observe section: config path + scope
  (system MDM / user setup / env), org, installation id, daemon socket
  probe, self-serve LaunchAgent presence (with a warning when an MDM
  install coexists), and the token-rejected breadcrumb

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@michiosw michiosw force-pushed the selfserve-setup-command branch from 4c34bc7 to 706dd46 Compare June 13, 2026 11:30
@michiosw michiosw force-pushed the selfserve-auth-devx branch from ab1ffbb to 7a6ba53 Compare June 13, 2026 11:30
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