[GH-ISSUE #193] refactor(application): share bounded JSON traversal logic for workspace and evidence bundle readers #141

Closed
opened 2026-10-15 18:21:34 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @morluto on GitHub (Jul 14, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/193

Problem

InvestigationWorkspaceStore and BoundedJsonFiles both enforce EvidenceFilePolicy limits through their own stack-based JSON traversal. The logic is currently duplicated across two modules and has already been the source of a real enforcement bug in one path in this codebase.

Evidence

  • src/application/BoundedJsonFiles.ts (readBoundedJson)
  • src/application/InvestigationWorkspaceStore.ts (withinJsonLimits)

Both implementations are separate and easy to drift, so a policy bug can reappear in one consumer without test coverage in the other.

Impact

  • Risk of inconsistent enforcement of maxDepth / maxNodes / maxStringLength between evidence bundle reads and investigation workspace reads.
  • Increased maintenance burden as constraints evolve.

Suggested fix

  • Extract a shared bounded-json validator utility and use it from both modules.
  • Add regression tests in both read paths to cover nested object/array traversal and depth/node limits.
Originally created by @morluto on GitHub (Jul 14, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/193 ## Problem `InvestigationWorkspaceStore` and `BoundedJsonFiles` both enforce `EvidenceFilePolicy` limits through their own stack-based JSON traversal. The logic is currently duplicated across two modules and has already been the source of a real enforcement bug in one path in this codebase. ## Evidence - `src/application/BoundedJsonFiles.ts` (`readBoundedJson`) - `src/application/InvestigationWorkspaceStore.ts` (`withinJsonLimits`) Both implementations are separate and easy to drift, so a policy bug can reappear in one consumer without test coverage in the other. ## Impact - Risk of inconsistent enforcement of `maxDepth` / `maxNodes` / `maxStringLength` between evidence bundle reads and investigation workspace reads. - Increased maintenance burden as constraints evolve. ## Suggested fix - Extract a shared bounded-json validator utility and use it from both modules. - Add regression tests in both read paths to cover nested object/array traversal and depth/node limits.
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#141
No description provided.