kylon-cli 0.4.1-next.740 → 0.4.1-next.741

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -537,6 +537,81 @@ instead of waiting out inactivity timeouts and heartbeat intervals.
537
537
  without the advertisement fails over-budget assignments with a named error
538
538
  instead of receiving flags it would misparse.
539
539
 
540
+ ## Remote diagnostics
541
+
542
+ The CLI sends selected structured lifecycle events to the same API-to-Grafana
543
+ Loki pipeline as web/mobile (`POST /client-logs/cli`, `service=cli-client`,
544
+ `client_kind=cli`). This is event logging, not OpenTelemetry/Tempo tracing.
545
+ It uses the credential selected by the running command or computer daemon;
546
+ it never ships Grafana credentials or falls back to another saved identity.
547
+ Status (`status`/`auth status`, `gateway status`), `diagnose`, and upgrade commands
548
+ (`upgrade`, `provider update`, `gateway service`) use a fixed unauthenticated
549
+ diagnostic path on the same URL. Login failures use that path too; successful
550
+ login selects its issued credential. Other commands never fall back to anonymous
551
+ submission when authentication fails. The anonymous handler reuses support-report
552
+ IP resolution/rate-limiting but has a separate quota and never creates support
553
+ reports or uploads diagnostic bundles.
554
+
555
+ Telemetry initialization calls the existing installation store's `ensure()`:
556
+ `install.json` in the CLI configuration directory contains the random `installId`,
557
+ which is included as `install_id` on both authenticated and anonymous records.
558
+ It is created before login and reused across runs. Deleting the file resets it;
559
+ copying the configuration can duplicate it. It identifies an installation, not
560
+ a physical device or authenticated person. With a stable identifier these are
561
+ pseudonymous diagnostics, not unlinkable anonymous data. No hardware fingerprint
562
+ is collected. If the installation cannot be read/created, telemetry stays off.
563
+ Opt-out is checked before initializing the installation for telemetry.
564
+
565
+ Set `KYLON_TELEMETRY_DISABLED=1` in the CLI/daemon process environment to disable
566
+ remote diagnostics; local diagnostic logs are unchanged. Restart an already
567
+ running daemon after changing its environment. This optional client-only switch
568
+ does not require any server/Doppler configuration.
569
+
570
+ Only events and fields listed in `@p2/types/cli-telemetry` are accepted on both
571
+ ends. Metadata includes CLI version (`app_version`), OS, architecture, client
572
+ timestamp, operation ID, existing task/request IDs, durations and error codes.
573
+ Raw argv, URLs, paths, hostname, prompts, provider output and credentials are
574
+ not uploaded. Identity/workspace attribution comes from server authentication,
575
+ not client fields. These are untrusted diagnostics, not an audit log.
576
+
577
+ The queue holds at most 100 records, sends at most 20 every five seconds, and
578
+ drops failed batches without retrying. Requests have an 800 ms timeout and do
579
+ not follow redirects. Normal command completion flushes the latest batch;
580
+ shutdown can wait for an in-flight request and one final request (up to roughly
581
+ 1.6 seconds). Hard kills and immediate `process.exit()` paths can lose events.
582
+ The API limits each authenticated identity to 60 batches/minute and 32 KiB/batch.
583
+ Anonymous diagnostics are limited separately to 20 batches/minute per source IP
584
+ (hashed for the rate-limit key), with the same size cap. Only command lifecycle
585
+ events and a narrower metadata allowlist are accepted; task/workspace/user IDs,
586
+ arbitrary error text and request IDs are dropped. The installation ID is supplied
587
+ by the client and is not an authentication or rate-limit credential. Existing
588
+ infrastructure request logs may retain network metadata; this change does not
589
+ introduce or alter a retention policy.
590
+
591
+ ### Event inventory
592
+
593
+ This change adds **5 event names at 6 logging call sites**:
594
+
595
+ - `cli.command.started`
596
+ - `cli.command.completed` (includes nonzero `process.exitCode` outcomes)
597
+ - `cli.api.failed` (network exception and HTTP failure call sites)
598
+ - `computer.connection.opened`
599
+ - `computer.connection.closed`
600
+
601
+ It also forwards **25 existing event names**, covering command failure,
602
+ gateway connection failures/reconnect scheduling, assignment receipt/acceptance,
603
+ provider execution, cancellation, result delivery/outbox replay, supervisor
604
+ lifecycle and upgrade outcomes. The shared allowlist is the exact inventory.
605
+ Unexpected command exceptions now reuse `cli.command_failed` instead of an
606
+ unstructured event name. Workspace API failures are captured in the shared
607
+ workspace client; other HTTP clients retain their existing selected diagnostics.
608
+ Successful HTTP requests are not uploaded in this first version.
609
+
610
+ Validation extends the existing logger and API route tests, plus the real
611
+ credential/middleware integration test for CLI/computer keys and forbidden
612
+ sibling/read routes. Live customer-machine-to-Grafana verification is still
613
+ required after deployment; these tests do not prove Grafana delivery.
614
+
540
615
  ## State Model
541
616
 
542
617
  The CLI uses a per-agent installation profile and three runtime-state layers:
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.4.1-next.740",
3
- "fingerprint": "773368feba78a11fe7d89106f9800f3e61453a3f3000aff625f1b0c15e836e5a",
4
- "source_commit": "5ed4b1657bc2887af0afe3323a5c354b43e4b237"
2
+ "version": "0.4.1-next.741",
3
+ "fingerprint": "e1e127852d0679e45bc6178d57a13f743f0482f1e76889ef799d99f5430643e6",
4
+ "source_commit": "4ddb875a1363443f2f3f515dd475a83fbd9be490"
5
5
  }