Skip to content

Preserve machine-applicable patches across artifact redaction #1837

Description

@chubes4

Problem

Runner-workspace publication can deterministically fail when an unchanged patch context line contains the name of a configured secret. Artifact redaction rewrites that identifier before the canonical patch reaches host application, so git apply receives a patch that no longer matches the byte-identical target workspace.

Observed in Build with WordPress manual Docs Agent acceptance:

The rejected patch replaced an existing literal secret identifier in an unchanged context line with [REDACTED:configured-secret-name]. The target checkout still contained the original identifier, so the redacted patch could not apply. The agent otherwise produced the intended documentation correction.

Root cause

packages/runtime-playground/src/artifact-bundle-builder.ts constructs files/patch.diff by passing the canonical workspace patch through ArtifactRedactor. ArtifactRedactor registers configured secret names as literal replacements. packages/runtime-core/src/runner-workspace-apply.ts subsequently treats that reviewer-safe redacted artifact as the machine-applicable canonical patch.

This conflates two contracts:

  1. A byte-preserving internal patch used for trusted host application.
  2. A redacted reviewer/upload artifact safe for durable publication.

Acceptance criteria

  1. Host application consumes a byte-preserving patch whose context still matches the verified seed identity.
  2. Reviewer-facing and uploaded artifacts retain secret redaction; no configured secret values leak.
  3. Any unredacted apply material is transient, bounded to the trusted apply path, and absent from uploaded/durable artifacts.
  4. Deterministic coverage modifies a file whose unchanged patch context contains a configured secret name, then proves host apply and publication preparation succeed.
  5. Existing artifact-redaction and runner-workspace integrity tests remain green.

Reproduction

  1. Configure a runtime secret named OPENAI_API_KEY.
  2. Mount a tracked repository containing the literal text OPENAI_API_KEY in a line adjacent to an intended edit.
  3. Produce a sandbox edit so the literal appears as unchanged patch context.
  4. Apply the emitted canonical patch through applyRunnerWorkspacePatch.
  5. Observe that the artifact contains [REDACTED:configured-secret-name] and git apply rejects it against the unchanged seed.

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