[PR #1456] [MERGED] fix(process)!: preserve literal replacement and comparison semantics #2898

Closed
opened 2026-10-17 21:11:33 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1456
Author: @Madhan0zx
Created: 10/10/2026
Status: ✅ Merged
Merged: 10/10/2026
Merged by: @N0zoM1z0

Base: main ← Head: fix/investigate


📝 Commits (3)

  • 96318b6 fix(process): normalize scenario replacements literally
  • 022c8b6 chore(process): integrate literal normalization with current main
  • 561877a fix(process)!: version literal scenario replacement semantics

📊 Changes

5 files changed (+133 additions, -2 deletions)

View changed files

📝 docs/process-capture.md (+8 -0)
📝 src/domain/process/processScenario.ts (+3 -0)
📝 src/process/capture/ProcessNormalization.test.ts (+51 -1)
📝 src/process/capture/ProcessNormalization.ts (+6 -1)
📝 tests/boundary/process/processCaptureNormalization.test.ts (+65 -0)

📄 Description

Summary

Process capture now inserts caller-selected normalization replacements verbatim. For a real target emitting AB, {pattern: "AB", replacement: "$&$&"} previously recorded ABAB; it now records $&$&, while retaining the original AB PTY output. Dollar sequences do not expand into matched text or surrounding output.

A replacement callback preserves the already-admitted empty-pattern semantics, including the first and last positions and empty input. For {pattern: "", replacement: "-"}, AB remains -A-B-.

Captures with custom patterns commit pattern_normalization_version: "literal-replacements-v1". Without that version, an actual old/new comparison reported a terminal change caused entirely by REA's replacement correction. CLI and MCP now refuse that mixed comparison and name the incompatible version field. Current-version comparisons continue to work. Captures without custom patterns retain their existing comparison contract.

Relates to #1065; that broader roadmap remains open. Original contributor history is preserved, with maintenance follow-up commits on this existing PR.

Validation

  • 98 focused tests pass across capture normalization, real PTY boundaries, capture validation, comparison, CLI and MCP adapters. The new empty-input module control fails against the original split/join PR implementation. Real capture controls retain raw output and check legacy refusal and same-version comparison.
  • Actual compiled public CLI and pinned SDK stdio MCP run a source-owned 28-byte Node target. Dollar literals and empty-pattern positions are correct; selected patterns and the input SHA-256 remain intact. Successful replies have text/structured parity, owned process-group cleanup is verified, temporary roots are removed, and ping succeeds after the rejected comparison.
  • Actual pre-fix public CLI controls establish both the main replacement expansion and the original PR's missing empty-pattern boundaries. The previously unversioned callback control also reproduces the misleading old/new comparison. These attempts are retained with the verification artifacts.
  • Full serial compile/typecheck, lint, unchanged duplication gate, generated-document checks and changed-file formatting pass under the documented two-CPU/process-family limits, pinned Node 24.18.0/npm 11.16.0.

Real-provider verification scope is local Linux PTY/process capture. Windows and macOS process capture remain subject to fresh current-head CI and are not claimed as independent local verification. No model-token or overall performance gain is claimed from this correctness fix.

Compatibility

BREAKING CHANGE: New captures with custom normalization patterns use literal-replacements-v1 and cannot be compared with legacy unversioned pattern captures. Capture both sides with the same replacement semantics. Legacy captures remain readable; captures without custom patterns retain their existing comparison contract. No input fields or execution authority are added.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1456 **Author:** [@Madhan0zx](https://github.com/Madhan0zx) **Created:** 10/10/2026 **Status:** ✅ Merged **Merged:** 10/10/2026 **Merged by:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Base:** `main` ← **Head:** `fix/investigate` --- ### 📝 Commits (3) - [`96318b6`](https://github.com/morluto/rea/commit/96318b66a08b987a46b1a545ce00f48bb27f99e9) fix(process): normalize scenario replacements literally - [`022c8b6`](https://github.com/morluto/rea/commit/022c8b6f5355b73f59a4f91188c064b8849f894f) chore(process): integrate literal normalization with current main - [`561877a`](https://github.com/morluto/rea/commit/561877ad763b9705b9298f1259a33fb98aed67a4) fix(process)!: version literal scenario replacement semantics ### 📊 Changes **5 files changed** (+133 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `docs/process-capture.md` (+8 -0) 📝 `src/domain/process/processScenario.ts` (+3 -0) 📝 `src/process/capture/ProcessNormalization.test.ts` (+51 -1) 📝 `src/process/capture/ProcessNormalization.ts` (+6 -1) 📝 `tests/boundary/process/processCaptureNormalization.test.ts` (+65 -0) </details> ### 📄 Description ## Summary Process capture now inserts caller-selected normalization replacements verbatim. For a real target emitting `AB`, `{pattern: "AB", replacement: "$&$&"}` previously recorded `ABAB`; it now records `$&$&`, while retaining the original `AB` PTY output. Dollar sequences do not expand into matched text or surrounding output. A replacement callback preserves the already-admitted empty-pattern semantics, including the first and last positions and empty input. For `{pattern: "", replacement: "-"}`, `AB` remains `-A-B-`. Captures with custom patterns commit `pattern_normalization_version: "literal-replacements-v1"`. Without that version, an actual old/new comparison reported a terminal change caused entirely by REA's replacement correction. CLI and MCP now refuse that mixed comparison and name the incompatible version field. Current-version comparisons continue to work. Captures without custom patterns retain their existing comparison contract. Relates to #1065; that broader roadmap remains open. Original contributor history is preserved, with maintenance follow-up commits on this existing PR. ## Validation - 98 focused tests pass across capture normalization, real PTY boundaries, capture validation, comparison, CLI and MCP adapters. The new empty-input module control fails against the original split/join PR implementation. Real capture controls retain raw output and check legacy refusal and same-version comparison. - Actual compiled public CLI and pinned SDK stdio MCP run a source-owned 28-byte Node target. Dollar literals and empty-pattern positions are correct; selected patterns and the input SHA-256 remain intact. Successful replies have text/structured parity, owned process-group cleanup is verified, temporary roots are removed, and ping succeeds after the rejected comparison. - Actual pre-fix public CLI controls establish both the main replacement expansion and the original PR's missing empty-pattern boundaries. The previously unversioned callback control also reproduces the misleading old/new comparison. These attempts are retained with the verification artifacts. - Full serial compile/typecheck, lint, unchanged duplication gate, generated-document checks and changed-file formatting pass under the documented two-CPU/process-family limits, pinned Node 24.18.0/npm 11.16.0. Real-provider verification scope is local Linux PTY/process capture. Windows and macOS process capture remain subject to fresh current-head CI and are not claimed as independent local verification. No model-token or overall performance gain is claimed from this correctness fix. ## Compatibility BREAKING CHANGE: New captures with custom normalization patterns use `literal-replacements-v1` and cannot be compared with legacy unversioned pattern captures. Capture both sides with the same replacement semantics. Legacy captures remain readable; captures without custom patterns retain their existing comparison contract. No input fields or execution authority are added. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:11:33 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#2898
No description provided.