Skip to content

feat(runtime): add GPT-compatible ApplyPatch editing projection #1552

Closed

Description

@Astro-Han

Problem

#1383 accepted ApplyPatch and Code Mode as independent axes of one model-specific tool-protocol profile. GPT coding models trained on an ApplyPatch-style protocol should not receive Maka's Edit/Write surface at the same time, but Maka must retain one execution, permission, sandbox, and durability path.

Scope

Add a GPT-compatible apply_patch capability as an editing projection over the effective per-run tool surface from #1493.

  1. Extend the normalized run policy with an editing override: current Edit/Write or ApplyPatch.
  2. When ApplyPatch is selected, replace the equivalent Edit and Write tools; never advertise both editing protocols in one effective surface.
  3. Accept the Codex-compatible patch envelope with Add, Update, Delete, and Move operations.
  4. Reuse the existing workspace executor/filesystem worker, path containment, write locks, permission planners, sandbox policy, artifact/diff events, telemetry, and ToolRuntime settlement.
  5. Expose the capability through the shared runtime and standard Desktop, CLI, and Headless composition paths. Do not add a Headless-only patch executor.
  6. Keep the current editing surface as the default. This issue adds an explicit per-run override but does not enable a model default.

Under CodeModeOnly, ApplyPatch is an ordinary nestable tool and is available only through exec; this issue must not depend on Code Mode to ship.

Patch semantics

  • Parse and preflight the complete patch before the first workspace mutation.
  • A syntax error, path violation, missing target, or hunk mismatch leaves the workspace unchanged.
  • Apply writes through the existing per-path lock and permission boundary.
  • Report every changed path and operation in the structured result.
  • If an I/O failure occurs after mutation begins, return an explicit partial-failure result naming completed and uncompleted operations; never report silent success.
  • Preserve existing line endings when updating an existing file unless the patch explicitly changes them.
  • Reject absolute paths and paths that escape the effective workspace authority, including through symlinks.

Acceptance

  • The effective surface contains exactly one editing protocol.
  • ApplyPatch uses the same permission, sandbox, durable T1/T2, telemetry, artifact, and UI paths as existing file edits.
  • Add, Update, Delete, Move, multi-file, mismatch, traversal, symlink, concurrency, and partial-I/O behavior have contract tests.
  • Scoped child bindings cannot regain Edit/Write or ApplyPatch when the parent surface omitted them.
  • Desktop, CLI, and Headless derive the same editing projection from the normalized policy.
  • A small controlled A/B against Edit/Write holds model, prompt, task, executor, and orchestration mode constant. Record correctness, provider steps, tokens/context, environment actions, and wall time as PR evidence.
  • The current editing protocol remains available as an explicit rollback.

Non-goals

  • Adding Code Mode or exec / wait.
  • Changing model defaults.
  • Building a second workspace executor or patch-specific permission system.

Depends on #1493. Part of #1383.

Activity

  1. added
    enhancement
    on Jul 28, 2026
  2. sunheyi6 commented on Jul 28, 2026

    @sunheyi6
    Contributor

    I'd like to claim this issue and implement it as specified.

    Planned scope (per the issue, no expansion):

    • Depend on refactor(runtime): project one effective product-tool surface per run #1493's effective per-run tool surface; add an editing-protocol override (Edit/Write or ApplyPatch, never both).
    • Codex-compatible apply_patch envelope (Add / Update / Delete / Move) as a projection over the existing workspace executor, path containment, write locks, permissions, sandbox, artifact/diff events, telemetry, and ToolRuntime — no second executor or Headless-only path.
    • Full parse + preflight before the first mutation; explicit partial-failure after mutation starts; path/symlink escape rejection; preserve line endings unless the patch changes them.
    • Shared composition for Desktop / CLI / Headless; current Edit/Write remains the default (explicit override only, no model-default change).
    • Contract tests for the acceptance cases, plus a small controlled A/B vs Edit/Write as PR evidence.
    • Out of scope: Code Mode / exec/wait, model defaults, and any patch-specific permission system.

    Please assign this issue to me if that works. I'll wait for assignment before opening a PR if preferred; otherwise I can start from the #1493 projection surface once the dependency is clear on main.

  3. Astro-Han commented on Aug 9, 2026

    @Astro-Han
    ContributorAuthor

    Closing as superseded by #2532, which implements the AI SDK native single-file ApplyPatch through Maka’s existing filesystem authority. User-facing availability is tracked separately in #2601. The former custom parser and editing-protocol projection are no longer planned.

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

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions