← Back to Pull requests

feat(artifacts): inspect Classic Mac OS PEF (Joy!peff) containers and loader tables offline #15140

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 30, 2026 00:49 UTC
Author

Summary

Classic Mac OS PowerPC and 68k CFM applications, shared libraries, and extensions ship in Apple's Preferred Executable Format (Joy!peff container header with architecture tag pwpc / m68k, section headers, and a loader section carrying imported libraries, imported symbols, exported symbols, and relocation tables). Today REA does not recognize PEF containers, so inspect-artifact cannot enumerate PEF sections or loader symbol tables and extract-artifact cannot pull raw code/data sections offline.

This adds an offline apple-pef artifact format. inspect-artifact and extract-artifact parse the Joy!peff container header and section table, decode loader imported libraries, imported/exported symbols, entry-point vectors (main/init/term), and relocation counts without applying relocations or executing code, and extract stored section bytes safely inside the output directory. 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 a Classic Mac OS .pef binary, inspect its container architecture (pwpc or m68k), section kinds/alignments/sizes, entry-point sections, imported libraries and symbols, exported symbols, and relocation counts offline, and extract stored sections into a contained output directory.

Change and scope

  • Added the domain parser src/domain/applePef.ts (with applePef.fixture.ts and applePef.test.ts) using BinaryReader to parse the 40-byte Joy!peff container header, 28-byte section headers, and loader section tables (imported libraries, imported symbols, exported hash/key/symbol tables, entry points, and relocation header counts) under bounded ceilings.

  • Added src/artifacts/ApplePefArtifactReader.ts (with unit and boundary tests) and registered apple-pef across artifactFormats.ts, artifactFormatRecognition.ts, artifactFormatMetadata.ts, artifactGraph.ts, targetFormats.ts, ArtifactReader.ts, artifactInventoryView.ts, appleMetadata.ts (or owning metadata module), scripts/ci/scopes.mjs, and scripts/verify/fixed-ceiling-registry.json.

  • Updated docs guide, 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: decompressing pattern-initialized (pidata) runtime sections into memory images, applying relocations, parsing MacBinary/Resource Fork wrappers, or executing 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/applePef.ts owns all Joy!peff header, section, and loader table parsing; ApplePefArtifactReader and inventory views consume the parsed facts directly.

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

  • CLI and MCP/tool-catalog contract: inspect-artifact and extract-artifact gain apple-pef recognition, section/loader inventory, and bounded section extraction.

  • 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: keeps observed section/loader tables distinct from unexpanded pidata or unapplied relocations and preserves truncation or ceiling limitations visibly.

  • 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: 6 test files covering domain PEF parsing, ApplePefArtifactReader, boundary/ceiling/truncation checks, format recognition, target vocabularies, and standalone artifact provider integration (151/151 tests passed).

  • Base reproduction or other evidence: Before this change, inspect-artifact did not recognize Joy!peff containers or decode PEF loader symbol/import tables. Synthetic fixtures cover valid pwpc containers with loader tables, truncated headers/sections, invalid loader indices, ceiling exhaustion, and extraction containment.

  • User-visible CLI/MCP output (if applicable): Ran node scripts/rea.mjs inspect-artifact and extract-artifact against synthetic ClassicApp.pef (385 B); observed root_format: apple-pef, coverage: complete, decoded section and loader tables, and 4 extracted entries with containment_verified: true.

  • Remaining proof gaps: Validated on synthetic spec-compliant and malformed fixtures only (no proprietary Classic Mac OS binaries included).
  • Boundary and lifecycle regressions: reader boundary tests and standalone artifact provider tests verify bounded reads, loader table ceilings, truncation handling, and extraction containment.

    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 across all 6 PEF/recognition/vocabulary/standalone test files — 6/6 files, 151/151 tests passed.

  • npm run verify:test-discovery — passed across 4085 test files.

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

  • npm run docs:check — passed.

  • node scripts/rea.mjs inspect-artifact / extract-artifact on synthetic ClassicApp.pef — verified apple-pef inventory, loader tables, 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 (apple-pef).

  • Security, privacy, process, or containment review: read-only BinaryReader positional parsing with ceilings registered in fixed-ceiling-registry.json, extraction containment verification, and no relocation application or code execution.
  • 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-102-feat-classic-macos-pef-container/out.mp4" controls width="720"></video>

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: mvanhorn Review duration: 846m
    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 #15140"
    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