Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions kernel_ai/api/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
("/process/<int:pid>/threads", "get_process_threads", h.get_process_threads, None),
("/process/<int:pid>/cpu", "get_process_cpu", h.get_process_cpu, None),
("/process/<int:pid>/fds", "get_process_fds", h.get_process_fds, None),
("/process/<int:pid>/lineage", "get_process_lineage", h.get_process_lineage, None),
("/process/<int:pid>/activity", "get_process_activity", h.get_process_activity, None),
("/processes-detailed", "get_processes_detailed", h.get_processes_detailed, None),
("/ipc-links", "get_ipc_links", h.get_ipc_links, None),
("/proc-matrix", "get_proc_matrix", h.get_proc_matrix, None),
Expand Down
27 changes: 19 additions & 8 deletions kernel_ai/contracts/api_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ class SecurityRealtimeResponse(TypedDict):

class FilesystemBlocksResponse(TypedDict):
timestamp: str
rows: int
cols: int
zones: list
blocks: list
mounts: list
devices: list
writepath: dict
writeback: dict
# None when no real block device exposes a scheduler (containers, ram-only).
io_scheduler: dict | None
meta: dict


Expand Down Expand Up @@ -151,11 +153,20 @@ def validate_security_realtime_response(payload: Any) -> None:
def validate_filesystem_blocks_response(payload: Any) -> None:
data = _expect_dict(payload, "filesystem_blocks")
_expect_key(data, "timestamp", str, "filesystem_blocks")
_expect_key(data, "rows", int, "filesystem_blocks")
_expect_key(data, "cols", int, "filesystem_blocks")
_expect_key(data, "zones", list, "filesystem_blocks")
_expect_key(data, "blocks", list, "filesystem_blocks")
_expect_key(data, "mounts", list, "filesystem_blocks")
_expect_key(data, "devices", list, "filesystem_blocks")
_expect_key(data, "writepath", dict, "filesystem_blocks")
_expect_key(data, "writeback", dict, "filesystem_blocks")
# A machine without a real block device reports no scheduler at all.
_expect_key(data, "io_scheduler", (dict, type(None)), "filesystem_blocks")
_expect_key(data, "meta", dict, "filesystem_blocks")
# The write-path strip and the headline are what the map actually draws.
_expect_key(data["writepath"], "stages", list, "filesystem_blocks.writepath")
_expect_key(data["writepath"], "hot", str, "filesystem_blocks.writepath")
_expect_key(data["writeback"], "dirty_mb", (int, float), "filesystem_blocks.writeback")
_expect_key(data["writeback"], "writeback_mb", (int, float), "filesystem_blocks.writeback")
_expect_key(data["meta"], "used_percent", (int, float), "filesystem_blocks.meta")
_expect_key(data["meta"], "mount_count", int, "filesystem_blocks.meta")


def validate_processes_realtime_response(payload: Any) -> None:
Expand Down
4 changes: 4 additions & 0 deletions kernel_ai/http/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
get_proc_timeline_branches,
get_process_cpu,
get_process_fds,
get_process_activity,
get_process_files,
get_process_lineage,
get_process_threads,
get_processes,
get_processes_detailed,
Expand Down Expand Up @@ -67,7 +69,9 @@
"get_process_cpu",
"get_process_fds",
"get_process_files",
"get_process_activity",
"get_process_kernel_map",
"get_process_lineage",
"get_process_threads",
"get_processes",
"get_processes_detailed",
Expand Down
8 changes: 8 additions & 0 deletions kernel_ai/http/api_handlers/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ def get_process_fds(pid):
return api_json(lambda: _process_inspect_service.get_process_fds_info(pid))


def get_process_lineage(pid):
return api_json(lambda: _process_inspect_service.get_process_lineage_info(pid))


def get_process_activity(pid):
return api_json(lambda: _process_inspect_service.get_process_activity_counters(pid))


def get_processes_detailed():
return api_json(lambda: {"processes": _processes_service.get_processes_detailed_data()})

Expand Down
24 changes: 0 additions & 24 deletions kernel_ai/http/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,30 +108,6 @@ def linux_devices_subsystem_html():
return redirect("/linux-devices-subsystem", code=301)


def linux_ebpf_subsystem_page():
return render_template("linux-ebpf-subsystem.html")


def ebpf_page_legacy():
return redirect("/linux-ebpf-subsystem", code=301)


def linux_ebpf_subsystem_html():
return redirect("/linux-ebpf-subsystem", code=301)


def linux_ebpf_cyberlab_page():
return render_template("linux-ebpf-cyberlab.html")


def ebpf_lab_page_legacy():
return redirect("/linux-ebpf-cyberlab", code=301)


def linux_ebpf_cyberlab_html():
return redirect("/linux-ebpf-cyberlab", code=301)


def health_check():
return jsonify(
{
Expand Down
4 changes: 2 additions & 2 deletions kernel_ai/ml/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from collections import deque
from dataclasses import dataclass, field

from kernel_ai.services.kernel_maps import SYSCALL_NAMES
from kernel_ai.services.kernel_maps import get_syscall_names

logger = logging.getLogger("kernel_ai.ml.sequence")

Expand Down Expand Up @@ -63,7 +63,7 @@ def sample(self) -> dict[int, str]:
continue
if num < 0:
continue
out[int(pid)] = SYSCALL_NAMES.get(num, f"sys_{num}")
out[int(pid)] = get_syscall_names().get(num, f"sys_{num}")
return out


Expand Down
Loading
Loading