Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 43 additions & 43 deletions src/reference/observability.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The primary goals are:

---

# 2. Observability Architecture
# 2. Observability architecture

```text
PsyDian Kernel
Expand Down Expand Up @@ -55,7 +55,7 @@ The architecture deliberately keeps observability separate from command authorit

---

# 3. Observability Layers
# 3. Observability layers

PsyDian observability is divided into:

Expand All @@ -69,7 +69,7 @@ Layer 5 → End-to-End Observability

---

# 4. Kernel Observability
# 4. Kernel observability

The kernel shall provide low-level logging through the available serial output mechanism.

Expand Down Expand Up @@ -113,7 +113,7 @@ Kernel logs are primarily intended for:

---

# 5. Log Levels
# 5. Log levels

PsyDian shall use consistent log levels.

Expand Down Expand Up @@ -159,7 +159,7 @@ Example:

---

# 6. Structured Log Format
# 6. Structured log format

Logs should remain consistent and machine-readable where practical.

Expand Down Expand Up @@ -187,11 +187,11 @@ The project should not require a full timestamp subsystem merely for logging.

---

# 7. Event Categories
# 7. Event categories

Important observability events include:

### Boot Events
### Boot events

```text
KERNEL_BOOT
Expand All @@ -200,7 +200,7 @@ SUBSYSTEM_INIT
BOOT_FAILURE
```

### Memory Events
### Memory events

```text
MEMORY_INIT
Expand All @@ -210,15 +210,15 @@ ALLOC_SUCCESS
ALLOC_FAILURE
```

### Interrupt Events
### Interrupt events

```text
EXCEPTION
HARDWARE_INTERRUPT
HANDLER_FAILURE
```

### Shell Events
### Shell events

```text
COMMAND_RECEIVED
Expand All @@ -227,15 +227,15 @@ COMMAND_EXECUTED
COMMAND_FAILED
```

### Diagnostic Events
### Diagnostic events

```text
DIAGNOSTIC_CREATED
DIAGNOSTIC_SENT
DIAGNOSTIC_RECEIVED
```

### AI Events
### AI events

```text
AI_REQUEST_STARTED
Expand All @@ -247,7 +247,7 @@ AI_REQUEST_FAILED

---

# 8. Diagnostic Observability
# 8. Diagnostic observability

Diagnostics should contain enough contextual information to identify:

Expand All @@ -273,7 +273,7 @@ Conceptual structure:

---

# 9. Request IDs and Correlation IDs
# 9. Request IDs and correlation IDs

PsyDian should use identifiers to correlate related events.

Expand Down Expand Up @@ -309,7 +309,7 @@ This makes it easier to determine which AI response corresponds to which diagnos

---

# 10. AI Bridge Logging
# 10. AI Bridge logging

The AI Bridge should log operational metadata such as:

Expand Down Expand Up @@ -338,7 +338,7 @@ Sensitive request payloads should not be logged by default.

---

# 11. Error Codes
# 11. Error codes

Stable internal error codes should be used.

Expand All @@ -359,7 +359,7 @@ PANIC-001 Kernel panic

The exact code registry will be finalized as the implementation grows.

### Codes Implemented in the Kernel
### Codes implemented in the kernel

Log lines use the format `[LEVEL][SUBSYSTEM][CODE] message`. Codes marked *diagnostic* also produce a structured diagnostic record and a protocol frame.

Expand Down Expand Up @@ -408,7 +408,7 @@ Log lines use the format `[LEVEL][SUBSYSTEM][CODE] message`. Codes marked *diagn

Metrics should focus on measurable system behavior rather than collecting unnecessary information.

## Kernel Metrics
## Kernel metrics

Potential metrics:

Expand All @@ -420,7 +420,7 @@ Potential metrics:
- Shell command processing time.
- Keyboard input processing rate.

## Communication Metrics
## Communication metrics

Potential metrics:

Expand All @@ -431,7 +431,7 @@ Potential metrics:
- Average message processing time.
- Communication latency.

## AI Bridge Metrics
## AI Bridge metrics

Potential metrics:

Expand All @@ -445,7 +445,7 @@ Potential metrics:
- Retry count.
- Provider error rate.

## AI Cost Metrics
## AI cost metrics

When supported by the selected provider:

Expand All @@ -455,7 +455,7 @@ When supported by the selected provider:

---

# 13. Recommended Performance Metrics
# 13. Recommended performance metrics

The MVP should prioritize:

Expand Down Expand Up @@ -491,7 +491,7 @@ PsyDian

---

# 14. AI Latency Breakdown
# 14. AI latency breakdown

The AI Bridge should ideally measure separate stages:

Expand Down Expand Up @@ -550,7 +550,7 @@ A request identifier should be retained throughout the flow where practical.

---

# 16. Kernel-to-Host Trace
# 16. Kernel-to-host trace

For a diagnostic event:

Expand Down Expand Up @@ -578,7 +578,7 @@ AI Bridge

---

# 17. External AI Trace
# 17. External AI trace

The AI Bridge should distinguish between:

Expand All @@ -595,7 +595,7 @@ This provides enough information to diagnose provider/API failures without loggi

---

# 18. Error Observability
# 18. Error observability

Errors shall receive stable internal codes and, where applicable, request/diagnostic identifiers.

Expand All @@ -618,7 +618,7 @@ Reason: AI request timeout.

---

# 19. Panic Observability
# 19. Panic observability

Kernel panics are particularly important because the kernel may no longer be able to perform normal processing.

Expand All @@ -643,7 +643,7 @@ The panic handler should avoid depending on complex functionality that may itsel

---

# 20. Failure Classification
# 20. Failure classification

Observability should make it possible to distinguish:

Expand Down Expand Up @@ -690,7 +690,7 @@ In the MVP, these can be represented through terminal/serial logs rather than a

---

# 22. Observability During Development
# 22. Observability during development

During development, the primary observability interface will be:

Expand Down Expand Up @@ -719,7 +719,7 @@ This provides immediate feedback during subsystem development.

---

# 23. Observability During AI Diagnostics
# 23. Observability during AI diagnostics

An AI-assisted diagnostic session may produce:

Expand Down Expand Up @@ -750,7 +750,7 @@ Suggested Investigation:

---

# 24. Privacy and Logging Rules
# 24. Privacy and logging rules

Observability must not become a source of unnecessary data exposure.

Expand All @@ -768,7 +768,7 @@ Where sensitive information may appear in user input or diagnostics, the bridge

---

# 25. Observability Data Retention
# 25. Observability data retention

For the MVP:

Expand All @@ -781,7 +781,7 @@ Future versions may add persistent diagnostic storage when a filesystem is avail

---

# 26. AI Observability
# 26. AI observability

AI-specific metadata should include:

Expand All @@ -800,7 +800,7 @@ The project should record model/provider information so AI behavior can be compa

---

# 27. Observability for AI Evaluation
# 27. Observability for AI evaluation

Observability data can support GenAI evaluation.

Expand All @@ -826,7 +826,7 @@ This allows the team to associate model behavior with a specific test scenario.

---

# 28. Development Dashboard / Visualization
# 28. Development dashboard / visualization

A dedicated dashboard is not required for the MVP.

Expand All @@ -850,7 +850,7 @@ This is future scope.

---

# 29. Observability Test Cases
# 29. Observability test cases

| ID | Scenario | Expected Result | Priority |
|---|---|---|---|
Expand All @@ -871,7 +871,7 @@ This is future scope.

---

# 30. Observability Requirements
# 30. Observability requirements

| ID | Requirement | Priority |
|---|---|---|
Expand All @@ -890,7 +890,7 @@ This is future scope.

---

# 31. MVP Observability Scope
# 31. MVP observability scope

## Required

Expand Down Expand Up @@ -923,7 +923,7 @@ Optional observability infrastructure must not delay core PsyDian development.

---

# 32. Final Observability Flow
# 32. Final observability flow

```text
Kernel Event
Expand Down Expand Up @@ -951,7 +951,7 @@ User

---

# 33. Observability Principles
# 33. Observability principles

### Visibility

Expand All @@ -969,18 +969,18 @@ Kernel, communication, bridge, and external AI failures should be distinguishabl

Observability must not expose credentials or unnecessary sensitive information.

### Low Overhead
### Low overhead

Logging and measurement should not excessively interfere with kernel operation.

### Determinism

Development and testing output should remain predictable and reproducible.

### AI Transparency
### AI transparency

AI-generated information should remain distinguishable from original kernel evidence.

### Graceful Degradation
### Graceful degradation

Core observability should continue even when the AI service is unavailable.
Loading