[PR #6876] [MERGED] fix(environment): match served items whose route repeats a separator #7428

Closed
opened 2026-11-01 21:47:47 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/6876
Author: @mhamzasakhi
Created: 10/23/2026
Status: ✅ Merged
Merged: 10/23/2026
Merged by: @gensokyo-dev

Base: main ← Head: fix/environment-repeated-separator-item


📝 Commits (3)

  • f894861 fix(environment): match served items whose route repeats a separator
  • f194c2a fix(environment): keep repeated-separator collections writable
  • c463198 Merge branch 'main' into fix/environment-repeated-separator-item

📊 Changes

3 files changed (+74 additions, -6 deletions)

View changed files

📝 src/application/environment/environmentStateAnswer.test.ts (+62 -0)
📝 src/application/environment/environmentStateCallLines.ts (+6 -5)
📝 src/application/environment/environmentStateCollections.ts (+6 -1)

📄 Description

Summary

Fixes #6847. A served item read whose captured route repeats a path separator, such as GET /api//books/1, returned AnalysisInputError ("The state holds no /api//books entity 1 in /api/books.") even though the entity was correctly extracted into collection /api//books. The single-separator route /api/books/1 succeeds, and direct recorded replay of the double-separator route also succeeds.

Problem and expected behavior

segmentsOf (the owner used to split the held collection path) preserves internal empty segments, so /api//books becomes ["api", "", "books"]. callSegments instead split the tool's path_template itself and dropped empty literal segments with if (text !== "") …, producing ["api", "books", value]. collectionMatch compares by position, so the lengths matched but the segments did not, and the item was reported as missing.

Expected: a state item view finds the entity it extracted from the same recorded path, preserving the empty internal segment when matching.

Change and scope

  • callSegments now splits the template through segmentsOf, the same owner that splits the held collection path, instead of re-implementing a split that dropped empty segments. A repeated separator is preserved identically on both sides.
  • Param positions are unchanged: param indices are already defined over segmentsOf(path_template) (see environmentStateCheckedLines.ts, which builds param index sets with segmentsOf(tool.path_template).flatMap(...)), and the reproduction confirms the /api//books/{numeric} param index is 3, matching segmentsOf.
  • Single-separator routes are unaffected: with no empty segment, segmentsOf and the previous raw split agree.
  • Create path (review follow-up): preserving empty literal segments exposed createdCollection's missing-argument guard, which rejected any empty segment. A generated create to a repeated-separator collection, such as POST /api//books, was refused. The guard now rejects only an empty supplied parameter segment, so an empty literal (the repeated separator) stays writable while a missing path argument is still refused. Recorded-replay creates were never affected.
  • Not included: the broader path-handling findings tracked in #6726 and #6696 (closed). This change addresses only the call-side split that diverged from segmentsOf.

Contribution scope: an ordinary correctness fix within existing boundaries; a maintainer scope decision is not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: call-path segmentation in callSegments, consumed by collectionMatch at the state-answer boundary.

  • CLI and MCP/tool-catalog contract: no schema change. A served item whose route repeats a separator now returns its entity instead of a not-found refusal.

  • Provider, bridge, target-format, or platform compatibility: none.

  • Evidence, artifact, provenance, or reconstruction contract: unchanged; state extraction already stored these collections distinctly.

  • Generated metadata, package, or installation impact: none.

  • Read existing files or captured data.

  • Launch or attach to a process.

  • Inject instrumentation or run scripts/code.

  • Change process memory, registers, files, or configuration.

  • Contact network services.

  • Recover protected code or work around protections.

  • Documentation or usability only; no target interaction.

  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added to src/application/environment/environmentStateAnswer.test.ts:

    • "answers a state item whose route has a repeated path separator": serves two captured items, /api/books/1 and /api//books/1, and asserts the double-separator item answers from /api//books while the single-separator item stays distinct under /api/books.
    • "creates into a collection whose route has a repeated path separator" (review follow-up): a generated create to /api//books returns 201 from state instead of a missing-argument refusal.
  • Base reproduction (executed): with only environmentStateCallLines.ts reverted, the item test fails with the issue's AnalysisInputError. With only the environmentStateCollections.ts guard change reverted, the create test fails with needs every path argument to be non-empty.

  • Reproduction of the reported issue (executed): the issue's synthetic HAR probe returned answer.ok: false for /api//books/1 before the change and answer.ok: true after, with /api/books/1 succeeding throughout.

  • Observed, derived, and inferred claims remain distinguishable.

  • Artifact identity, source provenance, and failed attempts remain preserved.

  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

Run on Ubuntu 24.04 x64 with Node 24.22.1:

  • npm run test:focused -- with every test file referencing environment state, callSegments, collectionMatch, answerFromState, createdCollection, environment-serve, segmentsOf or dyldPaths (47 files): 992 passed, 1 skipped, 0 failed.
  • npm run test:local -- src/application/environment/environmentStateAnswer.test.ts: 21 passed. With either fix reverted, its corresponding test fails.
  • npm run check:fast: passed. knip reports nothing for the touched module.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Only a previously failing served-item read begins succeeding; its collection extraction was already correct.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (synthetic capture; no provider). Linux only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new reads, execution, or network access.

Independent verification on updated main

Head c4631987 integrates main af3b039d. Independent Linux validation passed 310 targeted domain/service/CLI/MCP tests and full npm run check. A real Chromium HAR of a local package-inventory application was imported through compiled CLI/stdio MCP, projected to state and served through HTTP MCP: repeated-separator item reads and generated creates succeeded, with ordinary-path collections isolated. Original capture/manifest/state Evidence remained identical. Review and measured resource observations include verification scope, timing variation and token-estimate limitations.

CI run 40018253228 failed with 14 test failures, all reproduced on its clean base af3b039d; seven remaining shards were cancelled. Static/build/native-package checks and the agentenv export/run lane passed. Main then advanced to 0929fa42: the unchanged PR was re-integrated there, and the same 310 tests, full check and real Chromium/CLI/MCP workflow passed again. Final baseline and latest-main verification.

Author readiness

Human owner: @mhamzasakhi

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 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/6876 **Author:** [@mhamzasakhi](https://github.com/mhamzasakhi) **Created:** 10/23/2026 **Status:** ✅ Merged **Merged:** 10/23/2026 **Merged by:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Base:** `main` ← **Head:** `fix/environment-repeated-separator-item` --- ### 📝 Commits (3) - [`f894861`](https://github.com/morluto/rea/commit/f894861f165826fff7b49038ea682638f4880df7) fix(environment): match served items whose route repeats a separator - [`f194c2a`](https://github.com/morluto/rea/commit/f194c2a74fc1a5ab9fc8ba62986b6081736520fc) fix(environment): keep repeated-separator collections writable - [`c463198`](https://github.com/morluto/rea/commit/c463198726902753d79b8a8c2559dde27ef54af2) Merge branch 'main' into fix/environment-repeated-separator-item ### 📊 Changes **3 files changed** (+74 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/application/environment/environmentStateAnswer.test.ts` (+62 -0) 📝 `src/application/environment/environmentStateCallLines.ts` (+6 -5) 📝 `src/application/environment/environmentStateCollections.ts` (+6 -1) </details> ### 📄 Description ## Summary Fixes #6847. A served item read whose captured route repeats a path separator, such as `GET /api//books/1`, returned `AnalysisInputError` ("The state holds no /api//books entity 1 in /api/books.") even though the entity was correctly extracted into collection `/api//books`. The single-separator route `/api/books/1` succeeds, and direct recorded replay of the double-separator route also succeeds. ## Problem and expected behavior `segmentsOf` (the owner used to split the held collection path) preserves internal empty segments, so `/api//books` becomes `["api", "", "books"]`. `callSegments` instead split the tool's `path_template` itself and dropped empty literal segments with `if (text !== "") …`, producing `["api", "books", value]`. `collectionMatch` compares by position, so the lengths matched but the segments did not, and the item was reported as missing. Expected: a state item view finds the entity it extracted from the same recorded path, preserving the empty internal segment when matching. ## Change and scope - `callSegments` now splits the template through `segmentsOf`, the same owner that splits the held collection path, instead of re-implementing a split that dropped empty segments. A repeated separator is preserved identically on both sides. - Param positions are unchanged: param indices are already defined over `segmentsOf(path_template)` (see `environmentStateCheckedLines.ts`, which builds param index sets with `segmentsOf(tool.path_template).flatMap(...)`), and the reproduction confirms the `/api//books/{numeric}` param index is `3`, matching `segmentsOf`. - Single-separator routes are unaffected: with no empty segment, `segmentsOf` and the previous raw split agree. - Create path (review follow-up): preserving empty literal segments exposed `createdCollection`'s missing-argument guard, which rejected any empty segment. A generated create to a repeated-separator collection, such as `POST /api//books`, was refused. The guard now rejects only an empty *supplied* parameter segment, so an empty literal (the repeated separator) stays writable while a missing path argument is still refused. Recorded-replay creates were never affected. - Not included: the broader path-handling findings tracked in #6726 and #6696 (closed). This change addresses only the call-side split that diverged from `segmentsOf`. Contribution scope: an ordinary correctness fix within existing boundaries; a maintainer scope decision is not applicable. ## Contract and boundary impact - Semantic owner and earliest changed stage: call-path segmentation in `callSegments`, consumed by `collectionMatch` at the state-answer boundary. - CLI and MCP/tool-catalog contract: no schema change. A served item whose route repeats a separator now returns its entity instead of a not-found refusal. - Provider, bridge, target-format, or platform compatibility: none. - Evidence, artifact, provenance, or reconstruction contract: unchanged; state extraction already stored these collections distinctly. - Generated metadata, package, or installation impact: none. - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added to `src/application/environment/environmentStateAnswer.test.ts`: - "answers a state item whose route has a repeated path separator": serves two captured items, `/api/books/1` and `/api//books/1`, and asserts the double-separator item answers from `/api//books` while the single-separator item stays distinct under `/api/books`. - "creates into a collection whose route has a repeated path separator" (review follow-up): a generated create to `/api//books` returns 201 from state instead of a missing-argument refusal. - Base reproduction (executed): with only `environmentStateCallLines.ts` reverted, the item test fails with the issue's `AnalysisInputError`. With only the `environmentStateCollections.ts` guard change reverted, the create test fails with `needs every path argument to be non-empty`. - Reproduction of the reported issue (executed): the issue's synthetic HAR probe returned `answer.ok: false` for `/api//books/1` before the change and `answer.ok: true` after, with `/api/books/1` succeeding throughout. - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed Run on Ubuntu 24.04 x64 with Node 24.22.1: - `npm run test:focused --` with every test file referencing environment state, `callSegments`, `collectionMatch`, `answerFromState`, `createdCollection`, `environment-serve`, `segmentsOf` or `dyldPaths` (47 files): 992 passed, 1 skipped, 0 failed. - `npm run test:local -- src/application/environment/environmentStateAnswer.test.ts`: 21 passed. With either fix reverted, its corresponding test fails. - `npm run check:fast`: passed. `knip` reports nothing for the touched module. ## Compatibility, safety, and release - Breaking changes or migration steps: none. Only a previously failing served-item read begins succeeding; its collection extraction was already correct. - Real Hopper/Ghidra, browser, or OS coverage: not applicable (synthetic capture; no provider). Linux only. - Package or release metadata impact: none. - Security, privacy, process, or containment review: no new reads, execution, or network access. ## Independent verification on updated main Head `c4631987` integrates main `af3b039d`. Independent Linux validation passed 310 targeted domain/service/CLI/MCP tests and full `npm run check`. A real Chromium HAR of a local package-inventory application was imported through compiled CLI/stdio MCP, projected to state and served through HTTP MCP: repeated-separator item reads and generated creates succeeded, with ordinary-path collections isolated. Original capture/manifest/state Evidence remained identical. [Review and measured resource observations](https://github.com/morluto/rea/pull/6876#pullrequestreview-5634063144) include verification scope, timing variation and token-estimate limitations. CI run [40018253228](https://github.com/morluto/rea/actions/runs/40018253228) failed with 14 test failures, all reproduced on its clean base `af3b039d`; seven remaining shards were cancelled. Static/build/native-package checks and the agentenv export/run lane passed. Main then advanced to `0929fa42`: the unchanged PR was re-integrated there, and the same 310 tests, full check and real Chromium/CLI/MCP workflow passed again. [Final baseline and latest-main verification](https://github.com/morluto/rea/pull/6876#issuecomment-6374183028). ## Author readiness Human owner: @mhamzasakhi - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:47:47 +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#7428
No description provided.