This document defines the architecture of NecroScope v1. It specifies modules, responsibilities, interfaces, and how data flows through the system. See README.md "V1 limitations" for known gaps in the current implementation.
Architecture must stay aligned with:
DESIGN.mdfor high level goals and scopeINGESTION.mdfor how logs are parsed and normalizedOUTPUT.mdfor how results are representedTESTING.mdfor how behavior is validated
This file reflects the current v1 implementation. Sections marked as future work are not implemented yet.
NecroScope is conceptually split into three core layers:
- Ingestion - turn raw kernel logs into structured internal representations.
- Analysis - inspect the structured data, detect relevant events, and build higher level findings.
- Output - present results in deterministic formats suitable for humans and tools.
Each layer is implemented as one or more Python modules under a single top level package.
The v1 module layout follows this structure:
src/
necro_scope/
__init__.py
ingestion/
__init__.py
parser.py
detector.py
loader.py
calibration.py
analysis/
__init__.py
engine.py
rules.py # detection logic, classifiers, heuristics
severity.py
stacktrace.py
output/
__init__.py
formatter_json.py
formatter_text.py
schema.py
models/
__init__.py
analysis_result.py
error_block.py
events.py
log_metadata.py
util/
__init__.py
anonymize.py
text.py
timeparse.py
providers/
__init__.py
base.py
factory.py
heuristic.py
llm/
__init__.py
client.py
prompts.py
web/
__init__.py
app.py
routes.py
tests/
analysis/
ingestion/
output/
data/
Sections below define responsibilities and contracts for each area.
- Read raw logs from a source (file, stdin, etc).
- Tokenize and parse into a structured representation.
- Extract metadata such as kernel version and command lines.
- Boot boundaries are not detected in v1 and all events are assigned to boot 0.
- Hand back a well defined in memory structure for the analysis layer.
Details are specified in INGESTION.md.
- Consume the ingestion output.
- Detect errors, warnings, panics, oopses, and other notable events.
- Correlate events with kernel versions, boots, and relevant context.
- Produce a neutral internal representation of findings for the output layer.
Details are specified in DESIGN.md.
- Take analysis results and metadata.
- Produce deterministic, stable output formats (for example JSON and text summaries).
- Ensure ordering, naming, and structure match
OUTPUT.md.
At a high level, the data flow is:
-
Input
- Raw kernel log text (for example captured
dmesgoutput).
- Raw kernel log text (for example captured
-
Ingestion
- Parsing and normalization according to
INGESTION.md. - Construction of one or more internal objects representing boots, messages, and metadata.
- Parsing and normalization according to
-
Analysis
- Detection of interesting events.
- Grouping, classification, and enrichment of events.
-
Output
- Conversion of analysis results into the output structures defined in
OUTPUT.md. - Rendering to the final format that the user or caller sees.
- Conversion of analysis results into the output structures defined in
Future diagrams can be added here once the structures are finalized.
Key interfaces between layers for v1:
- Ingestion:
ingestion.ingest(lines)returns(LogMetadata, List[LogEvent], List[ErrorBlock]). - Analysis:
analysis.engine.analyze(metadata, events, error_blocks)returns anAnalysisResult. - Output:
output.formatter_json.format_json(result)andoutput.formatter_text.format_text(result)acceptAnalysisResult.
The dataclasses in src/necro_scope/models/ define the concrete schemas.
This section will define how each layer deals with bad or partial input, and how errors are surfaced.
Planned topics:
- What happens when ingestion encounters malformed lines.
- How multi boot logs with partial data are handled.
- How internal exceptions are translated into user visible signals.
- When to fail hard vs emit partial results with warnings.
To be completed.
Cross cutting concerns apply across ingestion, analysis, and output.
Planned topics:
- Logging and debug output for development.
- Configuration handling (if any) for v1.
- Privacy considerations when handling sensitive logs, consistent with
DESIGN.md. - Performance considerations for large logs.
To be completed.
NecroScope v1 should be architected to allow:
- Additional ingestion backends for other log formats.
- Additional analysis rules without breaking existing behavior.
- Additional output formats while keeping core structures stable.
- Optional Rust components in specific hotspots, if justified later.
This section will be expanded once v1 is more mature and concrete extension points are identified.
DESIGN.md- overall goals, scope, and requirements.INGESTION.md- ingestion rules and schemas.OUTPUT.md- output schemas and determinism rules.TESTING.md- fixtures, test types, and expectations.AGENTS.md- multi agent workflow and constraints for automated implementers and reviewers.