mirror of
https://github.com/stablyai/orca.git
synced 2026-10-08 08:02:32 +00:00
* chore(dead-code): drop 2k lines of unreachable exports and orphan modules Ran knip across every build entry (main, preload, renderer, popout, web, cli, relay, workers, forked sidecars, config scripts) and removed what no entry graph can reach. - 11 orphan modules nothing imported, plus one test that only covered them - 159 unused exports/types, with their now-dead helpers, imports and tests Each candidate was verified against dynamic references before deletion. 42 knip hits were false positives and are kept: shared modules consumed by the mobile/ workspace, the src/shared/plugins/** public API, vendored shadcn primitives, and relay wire-protocol constants held for compatibility. Adds knip.json + `pnpm audit:dead-code` so this stays measurable. Verified: pnpm typecheck, pnpm lint, and 2081 tests across the 73 affected test files all pass. * chore(dead-code): move knip config under config/ Root-level additions are blocked by the root directory guard. Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Orca <help@stably.ai>
46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
// Enums + bucketing for the `daemon_lifecycle` telemetry event (STA-2376).
|
|
// The daemon's own retirement cause (pam-rejections/probe-timeouts) lives in the
|
|
// subprocess and never crosses into the app, so every reason here is one the app
|
|
// itself decides: a startup replace, or an observed death→respawn.
|
|
|
|
// Startup launcher replaced a still-connectable daemon (each maps 1:1 to a `daemon-init.ts` decision).
|
|
export const DAEMON_REPLACE_REASONS = [
|
|
'unhealthy_resolver',
|
|
'stale_bundle',
|
|
'different_app_path',
|
|
'failed_health_check'
|
|
] as const
|
|
export type DaemonReplaceReason = (typeof DAEMON_REPLACE_REASONS)[number]
|
|
|
|
// Adapter observed the daemon die and forked a replacement.
|
|
export const DAEMON_RETIRE_REASONS = ['died_respawn'] as const
|
|
export type DaemonRetireReason = (typeof DAEMON_RETIRE_REASONS)[number]
|
|
|
|
export const DAEMON_LIFECYCLE_TRANSITIONS = ['replaced', 'retired'] as const
|
|
|
|
export const DAEMON_LIFECYCLE_REASONS = [
|
|
...DAEMON_REPLACE_REASONS,
|
|
...DAEMON_RETIRE_REASONS
|
|
] as const
|
|
|
|
// Bucketed, never raw: exact live-session counts could fingerprint heavy users. `unknown` when
|
|
// the count couldn't be verified (null) — e.g. a wedged daemon or an already-dead respawn target.
|
|
export const DAEMON_LIFECYCLE_SESSION_BUCKETS = ['0', '1', '2-5', '6+', 'unknown'] as const
|
|
export type DaemonLifecycleSessionBucket = (typeof DAEMON_LIFECYCLE_SESSION_BUCKETS)[number]
|
|
|
|
export function bucketDaemonLiveSessionCount(count: number | null): DaemonLifecycleSessionBucket {
|
|
if (count === null) {
|
|
return 'unknown'
|
|
}
|
|
if (count <= 0) {
|
|
return '0'
|
|
}
|
|
if (count === 1) {
|
|
return '1'
|
|
}
|
|
if (count <= 5) {
|
|
return '2-5'
|
|
}
|
|
return '6+'
|
|
}
|