Skip to content

exporter: map FileFactShard -> ripr-perl-facts-v1 packet in perl-lsp (Campaign 31 #1379) #1389

Closed as not planned

Description

@EffortlessSteven

exporter/packet-emitter: map FileFactShard -> ripr-perl-facts-v1 packet

Campaign: #1379 (Campaign 31)
Work item: exporter/packet-emitter (Lane 1 — producer / perl-lsp side)
Tracker: .ripr/goals/perl-repair-routing.toml
Repo: EffortlessMetrics/perl-lsp (active dev tree: perl-lsp-swarm)
Branch: exporter/perl-ripr-facts-emitter
Depends on: exporter/schema-file, exporter/launch-action

Problem

perl-lsp already produces a serde-serializable FileFactShard (crates/perl-workspace/src/workspace/workspace_index.rs:1138-1169, assembled in crates/perl-workspace/src/semantic/facts.rs:68-77) containing anchors, entities, occurrences, edges, import specs, provenance, dynamic-boundary occurrences, and per-category change hashes (PRODUCER_SCHEMA_VERSION=1). This is mature substrate.

But there is no code that maps this internal fact model into the ripr-perl-facts-v1 packet shape ripr consumes. The exporter action from exporter/launch-action currently stubs to a not-yet-implemented error.

Scope (perl-lsp repo)

Implement the emitter body: take the parsed/indexed Perl workspace facts and produce a ripr-perl-facts-v1 packet matching the schema from exporter/schema-file.

Mapping (FileFactShard -> ripr-perl-facts-v1)

The packet shape ripr consumes (per its perl.rs:157 PerlFactPacket and the reference expected packet) needs these arrays with closed-vocabulary enums:

  • files — from FileFactShard file metadata; assign FileRole (Source/Test/Helper/Generated/Config/Unknown). .t files → Test; .pm/.pl → Source; Makefile.PL/Build.PL/cpanfile → Config.
  • owners — from entity facts; map to OwnerKind (Package/Sub/Method/Script/ModuleInitializer/TestSub/Unknown). Includes package/name + byte range.
  • changes — derive from the diff (base..head) intersected with owner ranges; assign BehaviorHint (PredicateBoundary/ReturnValue/ExceptionPath/HashOrObjectField/OutputObserver/WarnObserver/LogObserver/CallEffect/Unknown) by inspecting the changed AST node.
  • tests — from test-discovery facts; assign TestFramework (Test::More/Test2::V0/Test2::Suite/Test::Exception/Test::Fatal/unknown) and RunnerHint.
  • oracles — from test-body assertion extraction; assign OracleKind + OracleStrength. This is the hardest mapping; start with what perl-lsp already extracts and map conservatively (unknown > wrong).
  • relations — from edge facts (call/reference/proximity); assign RelationKind + ReachabilityHint.
  • dynamic_boundaries — from the existing dynamic-boundary occurrences (eval_sub_extractor.rs, queries.rs:173-204); assign BoundaryKind (14 closed values).
  • verify_commands — derive from detected runner (prove/yath/carton/dzil) + test paths.
  • limitations — emit one per dynamic boundary or extraction gap.
  • provenance — from FileFactShard provenance with ProvenanceSource mapping.

Top-level packet fields

  • schema_version = "ripr-perl-facts-v1"
  • packet_id — deterministic hash of inputs (root + base + head + fact_classes + content hashes).
  • packet_status — Complete/Partial/Unavailable.
  • packet_fingerprint — content hash for freshness checks (ripr's ingestion/integrity-checks will verify this).
  • producer — name="perl-lsp", version, capabilities (the fact_classes actually emitted).
  • root, input — repo-relative, no host/drive paths.

The load-bearing test

The packet perl-lsp emits from ripr's sample input (fixtures/perl_lsp_facts_exporter/input/lib/My/App.pm + input/t/app.t) must match (or be a strict superset of) ripr's hand-authored expected/ripr-perl-facts-v1.json. This is the integration contract. If the live packet diverges meaningfully from the hand-authored one, coordinate with the ripr consumer side — either the hand-authored packet was aspirational (update it in a coordinated ripr PR) or the emitter is wrong (fix the emitter).

Failing fixture / proof

# perl-lsp repo
cargo test -p perl-lsp-rs-core
cargo test -p perl-workspace

Add a perl-lsp integration test that:

  1. Runs the emitter on the sample input (vendor a copy of fixtures/perl_lsp_facts_exporter/input/ into perl-lsp's test fixtures to avoid cross-repo runtime deps).
  2. Validates the output against schemas/ripr-perl-facts-v1.json.
  3. Diffs against the reference expected packet — assert field-by-field equivalence on the closed-vocabulary fields, or document and coordinate any intentional divergence.

Run the actual binary:

perl-lsp --ripr-facts --schema ripr-perl-facts-v1 --root <sample> --out facts.json
cat facts.json   # inspect

Acceptance

  • Emitter produces a schema-valid ripr-perl-facts-v1 packet from real Perl source.
  • The sample-input packet matches the reference expected packet (or divergence is documented + coordinated).
  • cargo test -p perl-lsp-rs-core, cargo test -p perl-workspace pass.
  • PR description shows the actual emitted packet (not just "tests pass").
  • Cross-links to consumer/productionize (ripr side) for the joint integration.

Dependencies

  • Depends on exporter/schema-file + exporter/launch-action.
  • Unblocks verification/end-to-end-mini-repo on the ripr side once ripr's consumer is also productionized.

Non-goals

  • Changing ripr's expected packet unilaterally (coordinate).
  • Perfect oracle extraction (start conservative; OracleKind::Unknown is acceptable where extraction is unsure — ripr's strict-actionability validator will fail closed on unknown oracles, which is the safe direction).
  • Supporting every Perl construct (fail closed with limitations for unsupported syntax).

Risk

This is the highest-skill work item in Lane 1. The oracle/relation/behavior mapping requires real Perl semantics. Pair with consumer/productionize reviewer to make sure the emitted shapes are consumable. If a mapping is too hard for v1, emit a LimitationFact and let ripr fail closed — never fabricate a confident fact.

Activity

  1. EffortlessSteven commented on Jun 21, 2026

    @EffortlessSteven
    MemberAuthor

    Superseded by the restructured Campaign 31 plan. This issue was scoped under the original plan, which violated ADR 0019 by keeping the Perl-local PerlStrictActionability as the actionability flip authority (ADR 0019 line 83-86 explicitly forbids parallel/mirror validators and language-local repair_packet_ready booleans). The restructured plan routes Perl through the shared GapRecord + validate_agent_gap_record_packet authority, mirrors the TypeScript projection pattern (typescript_gap_record_for + validator_parity_* tests), and upgrades the target from "preview loop" to "usable alpha" across 4 phases / 18 PRs.

    See the refreshed umbrella #1379 and the new planning PR for the phased issues. The substantive content of this issue is preserved and folded into the appropriate new phased issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions