← Back to Pull requests

feat(artifacts): inventory and extract Linux romfs filesystem images offline #15138

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 29, 2026 23:58 UTC
Author

Summary

Linux embedded firmware images frequently ship read-only root filesystems in the Linux romfs format (-rom1fs- superblock with 16-byte aligned file headers, 32-bit big-endian checksum, directories, regular files, hard links, symlinks, and device nodes). Today REA does not recognize romfs images, so inspect-artifact cannot enumerate their filesystem entries and extract-artifact cannot pull regular files out for downstream inspection without mounting the image.

This adds an offline linux-romfs artifact format. inspect-artifact and extract-artifact recognize -rom1fs- images by superblock structure and checksum verification, list directories, regular files, symlinks (preserving link_target), hard links, and special nodes with exact byte offsets and sizes, and extract regular files safely inside the output directory while omitting special nodes and symlink traversal. No issue exists for this; it is a read-only offline format addition within the supported contribution scope.

Problem and expected behavior

Use case: given an embedded rootfs.romfs image, list its volume name, superblock checksum status, directory tree, symlinks, and file sizes offline, and extract regular files (such as /etc/init.d/rcS or /bin/app) into a workspace directory with containment checks and bounded read ceilings.

Change and scope

  • Added the domain parser src/domain/firmware/romfs.ts (with romfs.fixture.ts and romfs.test.ts) to parse the -rom1fs- superblock, verify the 512-byte big-endian word checksum, walk 16-byte-aligned entry headers with cycle detection and bounded entry/depth/name ceilings, and classify regular files, directories, symlinks, hard links, and special device/socket/FIFO nodes.

  • Added src/artifacts/RomfsArtifactReader.ts (with unit and boundary tests) and registered linux-romfs across artifactFormats.ts, artifactFormatRecognition.ts, artifactFormatMetadata.ts, artifactGraph.ts, targetFormats.ts, ArtifactReader.ts, PositionalArtifactReader.ts, artifactInventoryView.ts, firmwareMetadata.ts, and scripts/verify/fixed-ceiling-registry.json.

  • Updated docs/guides/firmware/romfs-images.md, VitePress nav, CLI/supported-targets/limits docs, and authored skill references under .agents/skills/reverse-engineer-anything/ and .cursor-plugin/skills/reverse-engineer-anything/.

  • Out of scope: mounting images, writing/repacking romfs, or executing extracted binaries.
  • Follow the contribution scope. Not applicable for target execution/injection scope decisions: this is a strictly read-only offline file parser.

    Contract and boundary impact

  • Semantic owner and earliest changed stage: src/domain/firmware/romfs.ts owns all romfs byte parsing, checksum verification, cycle detection, and entry normalization; RomfsArtifactReader and inventory views consume the parsed domain result without re-parsing bytes.

  • Contribution scope fit and linked maintainer decision: fits read-only offline artifact/firmware inspection scope; no special maintainer scope decision required.

  • CLI and MCP/tool-catalog contract: inspect-artifact and extract-artifact gain linux-romfs recognition and inventory/extraction support with existing output schemas preserved.

  • Provider, bridge, target-format, or platform compatibility: pure TypeScript positional file reader; platform-independent across Linux, macOS, and Windows.

  • Evidence, artifact, provenance, or reconstruction contract: preserves superblock checksum validity, symlink targets, hard-link targets, omitted special nodes, and truncation/cycle limitations as explicit structured observations.

  • Target selection, authority, upstream behavior, and cleanup details (if applicable): read-only local file access with bounded positional reads and verified output containment on extraction.

  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: authored skill text updated in .agents/skills/reverse-engineer-anything/ and .cursor-plugin/skills/reverse-engineer-anything/; no generated build outputs committed.
  • Expected effects (check known effects; use documentation-only on its own).
    Unchecked items do not establish absence; leave uncertainties visible.

  • 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

  • Tests added or updated: src/domain/firmware/romfs.test.ts, src/artifacts/RomfsArtifactReader.test.ts, src/artifacts/RomfsArtifactReader.boundaries.test.ts, src/domain/artifactFormatRecognition.test.ts, src/application/binary/TargetFormatVocabularies.test.ts, tests/boundary/providers/native/artifactProvider.standaloneFormats.test.ts (6 files, 159 tests passed).

  • Base reproduction or other evidence: Before this change, inspect-artifact had no linux-romfs recognizer and fell back to raw/unrecognized bytes. After this change, synthetic fixture tests cover valid checksum, corrupt checksum, cyclic next-header offsets, out-of-bounds payloads, symlinks, hard links, special nodes, and extraction path containment.

  • User-visible CLI/MCP output (if applicable): Ran node scripts/rea.mjs inspect-artifact and extract-artifact against a synthetic 640-byte rootfs.romfs image; observed superblock checksum verified (sum 0), symlinks retained in link_target, special nodes omitted on extraction, and regular files extracted with containment_verified: true.

  • Remaining proof gaps: Tested against synthetic spec-compliant and malformed fixtures only (no proprietary firmware dumps included).
  • Boundary and lifecycle regressions: RomfsArtifactReader.boundaries.test.ts and artifactProvider.standaloneFormats.test.ts verify bounded reads, cycle termination, truncation handling, and extraction containment cleanup.

    For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.

  • Artifact identity, source provenance, and failed attempts remain preserved.

  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
  • Validation performed

  • npm run test:focused -- src/domain/firmware/romfs.test.ts src/artifacts/RomfsArtifactReader.test.ts src/artifacts/RomfsArtifactReader.boundaries.test.ts src/domain/artifactFormatRecognition.test.ts src/application/binary/TargetFormatVocabularies.test.ts tests/boundary/providers/native/artifactProvider.standaloneFormats.test.ts — 6 files, 159 tests passed.

  • npm run verify:test-discovery — passed (4083 test/spec files).

  • npm run check — passed (typecheck, lint, format:check, knip, metadata:check, verify:architecture-guards across 3332 files, knip:production, lint:typed).

  • npm run docs:check — passed (docs:check:built + 8/8 readmeConsistency tests).

  • node scripts/rea.mjs inspect-artifact / extract-artifact on synthetic rootfs.romfs — verified inventory, checksum status, omission of special nodes, and contained extraction.
  • Compatibility, safety, and release

  • Breaking changes or migration steps: none.

  • Real backend, browser, or OS coverage: not applicable; offline positional byte parser validated on Node 24 on Apple silicon macOS.

  • Package or release metadata impact: one new artifact format (linux-romfs).

  • Security, privacy, process, or containment review: reads local files through bounded positional reads with cycle detection, ceiling checks registered in fixed-ceiling-registry.json, and extraction containment verification. Special device nodes and symlinks are never materialized as host device files or escaping links.
  • AI was used for assistance.

    Author readiness

    Human owner: @mvanhorn

  • 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.
  • Author checklist (completed by the PR author before requesting review)

  • 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.

  • I ran every test, build, or measurement needed to validate this change, reported a browser, GPU, or environment gap only when that runtime or hardware is unavailable, and reported the checks I ran and their results without presenting inferred correctness or speedups as measured.

  • Comments explain constraints or non-obvious decisions; task history and conversations stay out of code and docs.

  • Documentation is concise and factual, without punchy slogans or promotional language.

  • This change fixes the root cause and follows the engineering rules in AGENTS.md.

  • Formatted input is interpreted once at the owning boundary, and consumers use the owner's parsed facts. See Interpret boundary facts once.

  • Combined failures preserve partial observations, remaining resources, and cleanup facts. See Own the lifecycle.

  • A hardcoded limit is an REA_ runtime setting with a default, floor, and maximum, unless a fixed ceiling has a stated reason. See Adding a runtime setting.
  • Demo


    !demo
    <video src="https://mvanhorn.github.io/pr-demo-assets/rea/2026-11-29-100-feat-linux-romfs-inventory/out.mp4" controls width="720"></video>

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: mvanhorn Review duration: 897m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.52) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #15138"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 29.7% · Safe to merge
    29.7%
    Repository