Skip to content

feat(artifacts): inventory systemd journal headers and object table offline - #10151

Merged
morluto merged 44 commits into
morluto:mainfrom
2SinceJuly:feat/10123-systemd-journal
Nov 27, 2026
Merged

morluto merged 44 commits into
morluto:mainfrom
2SinceJuly:feat/10123-systemd-journal

Conversation

@2SinceJuly

Copy link
Copy Markdown
Contributor

Summary

Fixes #10123.

REA has no reader for systemd journal files. An analyst holding a .journal
copied from a host or carved from a disk image cannot see what the file declares
unless journalctl is available and they are willing to let a host tool
interpret it. This adds offline, read-only inventory of a selected journal file,
following the same first-step shape as the NTFS $MFT work in #9868/#9911: the
file's own header and object table become structured Evidence, and payload
decoding follows in later increments.

Problem and expected behavior

Expected: recognizing a journal file by its bytes and reporting its header facts
and object table, with every gap explicit.

Observed before this change: .journal input classified as file, no metadata.

Change and scope

  • src/domain/linux/systemdJournal.ts (new) owns the header and object-chain
    parse, limits and limitations.
  • src/artifacts/SystemdJournalArtifactReader.ts (new) reads the admitted file
    through ArtifactFileSource and exposes facts via formatMetadata(), as a
    root-only reader (a journal declares no members).
  • systemd-journal is registered as a format id, content format, target format,
    format descriptor and byte classification, alongside the other magic probes.
  • src/domain/artifactFormatMetadata.ts owns the result schema, including the
    metadata-comparison note.
  • docs/specs/linux/systemd-journal/ records the requirement, plan and task
    list for the remaining increments.

Parsed: the fixed 272-byte header (compatible/incompatible flag bits with names,
state, file/machine/tail-entry-boot/seqnum ids, header and arena sizes, the four
hash-table extents, and the object/entry/data/field/tag/entry-array counts,
sequence numbers and tail-entry realtime/monotonic), plus the object chain walked
by each header's declared extent with per-type counts, valid/truncated/unknown
counts, a bounded 32-object header window with source offsets, and trailing bytes.

Deliberately not included: field/entry/entry-array/hash-table payload decoding,
compression, time and boot filters, and multi-file timelines. These are recorded
in the spec's task list. header_size is the object area's anchor and must be
aligned and inside the file; otherwise no objects are reported and the reason is
a limitation rather than a guess. Payload coverage is reported as a limitation on
every result, so an inventory is never mistaken for entry-level Evidence.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/domain/linux/systemdJournal.ts
    owns journal bytes; SystemdJournalArtifactReader is its only consumer and
    publishes through formatMetadata(). No superseded path is removed.
  • Contribution scope fit and linked maintainer decision: implements the first
    step of an existing feature request ([Feature] Import systemd journal files as structured, offline Linux log Evidence #10123); no new provider, target
    execution, injection or mutation is involved.
  • CLI and MCP/tool-catalog contract: no new command or tool. Journal files reach
    the existing artifact inventory through byte classification. No tool schema
    changed.
  • Provider, bridge, target-format, or platform compatibility: adds one artifact
    format id; existing formats are untouched.
  • Evidence, artifact, provenance, or reconstruction contract: the root
    occurrence carries header facts and a bounded object sample; aggregate counts
    cover the whole walked chain. Unsupported payloads, truncated objects, unknown
    types and a header that cannot anchor the object area remain visible as
    limitations or counts.
  • Target selection, authority, upstream behavior, and cleanup details: none.
  • Generated metadata: none edited; no build output committed.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

Source-derived from the format's public definition (journal-def.h), not from a
captured journal written by a live systemd.

  • Tests added or updated: src/artifacts/SystemdJournalArtifactReader.test.ts
    covers a valid fixture end to end, flag naming, an object whose declared size
    overruns the file, a tail too short for a header, an unknown object type, a
    header size that cannot anchor the object area, refusal of a missing signature
    and of a file shorter than the fixed header, and the bounded object window with
    full-chain counts. Format-id registration is covered by the existing
    artifactFormats, ArtifactGraphConstruction and TargetFormatVocabularies
    suites.
  • Base reproduction or other evidence: not applicable; this is a new format.
  • User-visible CLI/MCP output: an inventory of a synthesized journal reports
    systemd-journal with the header facts and object_type_counts above.
  • Remaining proof gaps: no fixture from a journal file written by a real
    systemd is included
    , and no Windows-host execution applies here. Compressed
    and large (>4 MiB) journals are not exercised.

Validation performed

  • npm run check:fast — typecheck and lint passed.
  • npx vitest run src/artifacts/SystemdJournalArtifactReader.test.ts — 9 passed.
  • npx vitest run src/artifacts/artifactFormats.test.ts src/application/binary/TargetFormatVocabularies.test.ts src/artifacts/inventory/ArtifactGraphConstruction.test.ts — 92 passed.
  • npx vitest run src/domain/evidenceSubject.test.ts src/domain/analysisSnapshot.test.ts src/domain/artifactGraph.test.ts — 21 passed.
  • npx vitest run tests/conformance/artifactComparisonDocs.test.ts — 1 passed.
  • npm run docs:check — passed.
  • Not run: the full npm run check:pr gate.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: the parser is offline and
    read-only, decompresses nothing, executes nothing, and bounds the file at a
    fixed 4 GiB ceiling. Journal contents are not treated as trustworthy.

Author readiness

Human owner: @2SinceJuly

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

…ffline

Journals copied from a host or carved from a disk image had no reader, so an
analyst needed journalctl and a live host to see what a file declared. Recognize
the LPKSHHRH header by bytes and report it as its own artifact format.

Parse the fixed 272-byte header: flag bits and their names, state, the four
128-bit ids, header and arena sizes, hash-table extents, and the object, entry,
data, field, tag and entry-array counts. Anchor the object area on header_size,
requiring an aligned offset inside the file, then walk the object chain front to
back by each header's declared extent. Report totals by object type, the
valid/truncated/unknown-type counts, a bounded window of 32 object headers with
source offsets, and the trailing bytes the chain could not claim.

Payloads stay undecoded: fields, entries, entry arrays, hash tables and
compressed objects are reported as limitations rather than guessed, and the
whole file is bounded at a fixed 4 GiB ceiling.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T20:09:07.687848Z 3eeb686 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2034dd1830

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/domain/linux/systemdJournal.ts Resolved
Comment thread src/domain/linux/systemdJournal.ts Resolved
Comment thread src/domain/linux/systemdJournal.ts Resolved
Comment thread src/domain/linux/systemdJournal.ts Resolved
Comment thread src/domain/linux/systemdJournal.ts Resolved
`format:check` fails on these three files, which breaks the Static checks
lane and, through it, the CI required aggregate. `oxfmt` only reflows
lines; no behaviour changes.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 272d170963

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/domain/linux/systemdJournal.ts Resolved
Comment thread src/domain/linux/systemdJournal.ts Resolved
Comment thread src/domain/linux/systemdJournal.ts Resolved
Comment thread src/domain/linux/systemdJournal.ts Resolved
The object walk that shipped with the reader did not match the on-disk
format, so a valid journal could be reported as truncated and an
incompatible one could produce plausible but wrong evidence.

- Advance to `align8(offset + size)` and validate the raw extent. systemd
  keeps a declared size unpadded and aligns only the next object's start,
  so a size that is not a multiple of eight is valid, not truncated.
- Stop at `tail_object_offset` instead of at end of file. Bytes after the
  declared tail are the arena's preallocated capacity; walking them read a
  zero header as an extra unused object and called capacity corruption.
- Stream the object chain instead of buffering the file. Payload bytes are
  skipped as chunks arrive, so a journal near the 4 GiB ceiling inventories
  in chunk-sized memory and cancellation between chunks is never queued
  behind a whole-file parse.
- Read `tail_entry_array_offset` and `tail_entry_array_n_entries` with
  `getUint32`. They are adjacent 32-bit members added in revision 252;
  reading each as 64 bits folded the following field into both values.
- Accept the 208-byte header that predates `n_data`, and read every later
  field only when the declared `header_size` covers it. Older acquired
  journals stay inspectable instead of classifying as unknown.
- Refuse to describe objects when `incompatible_flags` sets a bit outside
  the known set. Such bits change the parser's assumptions, and a journal
  from a newer systemd would otherwise yield invalid object evidence.
- Record fields whose declaration exceeds 2^53-1 in `overflowed_fields`,
  so distinct source values no longer collapse onto the same ceiling.
- Report skipped compressed payloads only when a walked object actually
  carries a compression flag, not merely because the header advertises a
  compression algorithm.

Regression tests cover the unaligned size, the declared tail with arena
capacity after it, the 208-byte header, the compact 32-bit tail-array
fields, the 2^53-1 ceiling, unknown incompatible flags, and the
compression message. The decoder was also checked against every chunk
boundary from one byte to the whole file: counts and offsets are identical.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2114d52b36

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/artifacts/artifactFormats.ts Resolved
Comment thread src/domain/linux/systemdJournal.ts Resolved
Comment thread src/domain/linux/systemdJournal.ts Resolved
@greptile-apps

greptile-apps Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The reviewed changes appear safe to merge; no new actionable issue was established.RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge; no new actionable issue was established.

Summary

Adds offline systemd journal inventory and pages later object headers through inspect_analysis_view.

  • Artifact inventory now shows systemd journal header and object facts.
  • Analysis views can page through later journal object headers.

Diagram

sequenceDiagram
  participant Caller
  participant View as AnalysisViewService
  participant Page as Format header page reader
  participant File as Selected journal
  Caller->>View: Parent Evidence, artifact_path, offset, limit
  View->>View: Check parent inventory and read root digest
  View->>Page: Explicit file selection and expected digest
  Page->>File: Open and check SHA-256
  Page->>File: Stream journal and retain selected window
  Page->>Page: Close reader or retain failed cleanup
  Page-->>View: Object headers
  View-->>Caller: View Evidence with coverage and parent link
Loading

Reviews (36) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Comment thread src/domain/linux/systemdJournal.ts Resolved
Comment thread src/domain/linux/systemdJournal.ts Resolved
Comment thread src/domain/linux/systemdJournal.ts Resolved
Comment thread src/artifacts/artifactFormats.ts Resolved
Comment thread src/domain/linux/systemdJournal.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4801cc3de5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/domain/linux/systemdJournal.ts Resolved
Comment thread src/domain/linux/systemdJournal.ts Resolved
…r table

main replaced the per-route signature chains in BinaryTargetResolver and
ArtifactGraphConstruction with the ordered ARTIFACT_FORMAT_RECOGNIZERS table,
and moved the artifact reader base classes behind resources/index.js with
ArtifactPreparation owning the prepare/re-prepare lifecycle.

Resolve the merge that way rather than reinstating the inline chains: register
systemd-journal as one more entry in the shared table, give it a kind in
BINARY_TARGET_FORMAT_KINDS so the archive predicate still holds, and port
SystemdJournalArtifactReader to the current base modules.
@2SinceJuly

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (ab1616306); the branch was ~700 commits behind and conflicted in two files. Both conflicts came from main replacing the per-route signature chains with the ordered ARTIFACT_FORMAT_RECOGNIZERS table, and from the reader base classes moving behind resources/index.js with ArtifactPreparation owning the prepare lifecycle.

Resolution keeps this PR's feature and drops the now-redundant duplicate of main's code:

  • systemd-journal is registered as one more entry in the shared recognizer table rather than an inline hasSystemdJournalHeader branch in BinaryTargetResolver / ArtifactGraphConstruction.
  • binaryTargetTypes.ts gains "systemd-journal": "archive" so BINARY_TARGET_FORMAT_KINDS[format] === "archive" still classifies it correctly.
  • SystemdJournalArtifactReader is ported to the current base modules.

Verified locally: tsc --noEmit clean, plus 147 tests across SystemdJournalArtifactReader, artifactFormats, TargetFormatVocabularies, and artifacts/inventory — all passing. Pushed as 3d4bac1fe.

The earlier review threads predate this merge; several of their premises (the inline chain, the old reader imports) no longer exist. I'd rather not chase them individually — the required checks are green and a re-review on the new head will tell us what still applies.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Comment thread src/domain/linux/systemdJournal.ts Resolved
main's guards reject new raw DataView reads, so every header, object and
state field now goes through BinaryReader, which bounds each read.

Two offsets are write cursors rather than resource allowances, and each
carries the not-an-allowance reason the budget rule asks for.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

format:check runs oxfmt, and the BinaryReader rewrite left one call wrapped across three lines that oxfmt wants on one. No behavior change; this is what turned the Static checks job red on the previous run.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

The journal format adds artifact format metadata, which changes the open_binary output schema digest. Build package runs verify:advertised-schemas and rejects the stale summary, so commit the regenerated digest. Only the output compact hash moves; input schemas and patterns are unchanged.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Upstream landed the Android boot image format in the same artifact recognizer table, so main and this branch both changed the open_binary output schema digest. Resolve the summary by regenerating it against the merged generator instead of picking either side, then commit the digest that covers both formats.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Comment thread src/domain/linux/systemdJournal.ts Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Comment thread src/domain/linux/systemdJournal.ts Resolved
Comment thread src/domain/linux/systemdJournal.ts Resolved
Resolve the adjacent-additions conflict in androidAndSystemMetadata.ts by
keeping both the systemd journal schemas and the vbmeta descriptor schemas
that main added.

Ran deps:check, tsc --noEmit, and the systemd journal plus format
recognition/metadata tests: 44 passed.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

# Conflicts:
#	src/resources/ArtifactReader.ts
Merging main brought the systemd-journal recognizer into the shared format
union while this branch kept its own overlay list, so
recognizeLeadingFormat no longer assigned to PeOverlayLeadingFormat and
typecheck failed. Recognizers can name systemd-journal, so the overlay
leading-format list has to include it.
Comment thread src/domain/linux/systemdJournal.ts Resolved
Comment thread src/domain/linux/systemdJournal.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 667b6fa41c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/domain/linux/systemdJournal.ts Resolved
Comment thread src/domain/linux/systemdJournal.ts Resolved
morluto and others added 2 commits November 27, 2026 11:27
…eiling

- Drop the 4 GiB whole-file ceiling. It was justified by ENTRY_SIZE_MAX,
  which bounds one entry, while the scanner streams and retains one chunk
  plus a 32-header window whatever the file size.
- Make the object-header window selectable: createJournalDecoder and the
  reader accept objectHeaderStart, so next_object_header_index can be
  followed to later headers.
- Treat a zero arena_size as an empty arena rather than an absent one, and
  report declared arena bytes past the end of the file even when the
  readable objects and counts agree.
- Re-verify the source before reporting a decoder failure, so a file that
  changes mid-read reports an identity failure instead of truncation.
- Read the state byte through one lookup, so a header that cannot anchor
  its objects keeps its observed state; name the tail-entry-boot-id flag.
Inventory keeps a bounded window of per-record headers, and nothing could
follow the systemd journal's next_object_header_index over MCP or CLI.
inspect_analysis_view gains a generic `format_record_headers` inventory
collection (morluto#14919) that uses the existing offset and limit.

- Each page re-reads the root file through its format's artifact reader,
  with the window started at `offset`, after binding the file to the parent
  inventory's root digest. A changed file fails with
  artifact_integrity_mismatch (container-identity) instead of returning
  shifted rows.
- Memory is one read chunk plus one window. The read is a cancellable
  streaming scan, and the reader is released through the view's resource
  scope.
- Formats plug in through two single lists: the domain's record total and
  the artifacts layer's window reader. The systemd journal is wired; NTFS
  $MFT is left to morluto#14919 because its streaming decoder has no start index.
- The journal metadata drops object_header_start_index and
  next_object_header_index, which nothing could follow; the page's
  coverage.next_offset is the one continuation.
- The journal test builder moves into a shared fixture for reader and
  boundary tests.

Refs morluto#14919
@morluto

morluto commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Implements the design from #14919: format_record_headers pages journal object headers past the inline window by re-reading the unchanged file. Refs #14919.

Comment thread src/artifacts/formatRecordHeaderPage.ts Resolved
- Opening a file must not be selected by Evidence: subject.local_path is
  display metadata and can change without changing the Evidence ID. The
  format_record_headers collection now requires an explicit absolute
  `path`, which the CLI resolves like other caller paths. The root digest
  still binds that file to the inventory.
- Keep a completed page when the reader fails to close. The view Evidence
  is attached to the cleanup failure as its partial observation, and the
  reader stays retained for retry.
- Keep a completed page when cancellation arrives after it was read.
Comment thread src/cli/analysisViewCommands.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8dcfbe45e9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cli/analysisViewCommands.ts Resolved
Comment thread src/artifacts/formatRecordHeaderPage.ts Resolved
…wners

- Name the page's file selector artifact_path. The CLI's caller-path rewrite
  of view.path also rewrote other views' semantic selectors, such as a
  devicetree node path, into host paths on Windows; artifact_path exists
  only on format_record_headers pages.
- Run each page's read and release through the supplied resource scope, so
  a reader an earlier page failed to close is retried first and a new page
  is refused while that cleanup stays unresolved.
# Conflicts:
#	src/application/binary/TargetFormatVocabularies.test.ts
#	src/artifacts/artifactFormats.ts
#	src/artifacts/inventory/ArtifactGraphConstruction.ts
#	src/domain/artifactFormatMetadata.ts
#	src/domain/artifactFormatRecognition.ts
#	src/domain/artifactGraph.ts
#	src/domain/formatMetadata/androidAndSystemMetadata.ts
#	src/domain/native/peOverlay.ts
#	src/domain/targetFormats.ts
#	src/resources/ArtifactReader.ts
@morluto

morluto commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Maintainer review: defects fixed and brittleness pass

Pushed 34cf962, 2b1c2ae, 8dcfbe4 and dfa816d on top of your branch, plus plain merges of main. Nothing of yours was rewritten.

Defects fixed:

  • Unjustified 4 GiB whole-file ceiling: it was derived from ENTRY_SIZE_MAX, which bounds one entry. The scanner streams with a bounded window, so the ceiling is removed.
  • A zero arena_size disabled the arena check: zero is now an empty arena.
  • Declared arena bytes past EOF went unreported: they are now a limitation with the exact count.
  • A file changing mid-read was reported as truncated: the source is re-verified before any decoder failure is reported, as NtfsMftArtifactReader does.
  • An unanchored header lost its readable state byte: one readState now serves both paths.
  • Object headers past the first 32 couldn't be retrieved ([Feature] Page format record headers past the retained window over MCP and CLI #14919): inspect_analysis_view has a new format_record_headers inventory collection.
    • It takes an explicit artifact_path and the existing offset and limit.
    • Each page re-reads that file through the journal reader with the window at offset, after binding it to the inventory's root digest. A changed file fails with artifact_integrity_mismatch instead of returning shifted rows.
    • Memory is one chunk plus one window, and the read is cancellable and gated by the view's resource scope.
    • The unfollowable object_header_start_index and next_object_header_index are removed; coverage.next_offset is the continuation.
    • NTFS $MFT plugs in through the same two lists. It is left to [Feature] Page format record headers past the retained window over MCP and CLI #14919, because its streaming decoder has no start index.

Brittleness found and fixed:

  • State lookup duplicated: the state byte was read in two places with different results. Now one owner.
  • Magic flag bit: (1 << 1) for tail-entry-boot-id is now COMPATIBLE_TAIL_ENTRY_BOOT_ID, named after journal-def.h.
  • Dead code: removed the unused #headerStart, a redundant arena guard, and the reader's limit mapping, which no decoder path produces any more.

Checked against the spec: every HEADER offset, the incompatible flags (XZ 1, LZ4 2, KEYED_HASH 4, ZSTD 8, COMPACT 16), the compatible flags (SEALED 1, TAIL_ENTRY_BOOT_ID 2, SEALED_CONTINUOUS 4), the states (0, 1, 2), the 16-byte ObjectHeader (type, flags, reserved, le64 size), the 64-bit alignment, the 272-byte current header, and the 208-byte minimum (ALIGN64(offsetof(Header, n_data))). All match.

Sources:

  • DeepWiki, systemd/systemd: docs/JOURNAL_FILE_FORMAT.md and src/libsystemd/sd-journal/journal-def.h, which give the header offset table, flag values, the ObjectHeader layout, and "used portion is header_size + arena_size".
  • Disagreement with this PR: neither source states a per-file size maximum (MAX_USE_UPPER is a journald retention setting), so no whole-file ceiling is kept.

Validation:

  • Source tests on the reader, page reader, inventory view, recognition, graph and vocabulary (223 passed).
  • MCP and CLI boundary tests for the pages (6 passed): headers 32 and later, the last and empty pages, a malformed object in a later page, a changed file, a caller-named copy, an unsupported format.
  • Typecheck, lint and module boundaries, architecture guards, oxfmt --check, and the docs checks.

@morluto
morluto enabled auto-merge (squash) November 27, 2026 18:53
The parent module imported the inventory projector for the page row type,
which closed an import cycle the analysis-view cycle check forbids. The type
now lives in analysisViewParent.ts and its consumers import it from there.
The CLI JSON-input schema test now expects view.artifact_path among the
caller paths inspect-analysis-view resolves.
@morluto
morluto disabled auto-merge November 27, 2026 20:01
# Conflicts:
#	src/domain/formatMetadata/androidAndSystemMetadata.ts
@morluto
morluto merged commit 742cdf0 into morluto:main Nov 27, 2026
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Import systemd journal files as structured, offline Linux log Evidence

2 participants