Skip to content

Slim preflight_workspace_verify event: sidecar full output, strip ANSI #92

Description

@EffortlessSteven

Problem

A single preflight_workspace_verify event in events.jsonl carries a full output string with the cargo workspace dry-run output, including raw ANSI escape codes like \u{1b}[1m\u{1b}[92m. This dominates the event log: one event ≈ 2KB; the other 26 events combined ≈ small. Persisting ANSI codes to a "structured" data file is wrong for downstream tooling, and the artifact bloats unnecessarily—most consumers don't need the full output, they need a summary.

Current behavior

  • Event definition (crates/shipper-types/src/lib.rs:1338, variant):
    PreflightWorkspaceVerify {
        passed: bool,
        output: String,  // <-- full cargo dry-run stderr with ANSI codes
    }
  • Event emission (crates/shipper/src/engine/mod.rs:156-163):
    event_log.record(PublishEvent {
        timestamp: Utc::now(),
        event_type: EventType::PreflightWorkspaceVerify {
            passed: workspace_dry_run_passed,
            output: workspace_dry_run_output.clone(),  // full output with ANSI
        },
        package: "all".to_string(),
    });
  • Cargo dry-run source (crates/shipper/src/engine/mod.rs:123-141):
    Output includes raw ANSI escape codes from cargo stderr, picked up in the format string and persisted as-is.

Proposed change

  • Keep in event: passed: bool, optional brief summary (e.g., exit code, first error line)
  • Move to sidecar: full output to .shipper/preflight_workspace_verify_output.txt
  • Apply ANSI stripping using existing shipper-output-sanitizer crate (already handles token redaction + ANSI should be easy addition) before writing sidecar OR before persisting in event

Implementation sketch

  1. Add ANSI stripping function to crates/shipper-output-sanitizer/src/lib.rs (e.g., strip_ansi(s: &str) -> String). Use existing crate like regex or simple pattern.
  2. Update EventType::PreflightWorkspaceVerify variant to hold only metadata:
    • passed: bool
    • exit_code: i32 (from dry-run result)
    • elapsed_ms: u64
    • Optional summary: Option<String> (first error line or empty on success)
  3. In engine/mod.rs:156-163, write full output to sidecar path .shipper/preflight_workspace_verify_output.txt and strip ANSI/tokens before writing.
  4. No Reporter trait changes needed; Reporter uses preflight summary, not full output.

Compatibility

Events.jsonl readers may rely on the output field. Options:

  • Option A: Keep output as a brief summary (safe, backward-compatible)
  • Option B: Remove output entirely and update CHANGELOG with migration guide (cleaner but requires consumer updates)
  • Recommend Option A for now; can migrate to Option B in v0.4.0.

Acceptance criteria

  • ANSI stripping works for mixed ANSI + token patterns
  • preflight_workspace_verify event is <100 bytes in most cases
  • Full output written to sidecar .shipper/preflight_workspace_verify_output.txt
  • Existing event snapshots in tests updated
  • events.jsonl file size for typical run reduced by >90%

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions