Skip to content

Parse logged multiline child JSON - #4

Merged
EauDoon merged 1 commit into
mainfrom
codex/cycle5-parse-multiline-json
Aug 29, 2026
Merged

Parse logged multiline child JSON#4
EauDoon merged 1 commit into
mainfrom
codex/cycle5-parse-multiline-json

Conversation

@EauDoon

@EauDoon EauDoon commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • accept pretty-printed object or array output after child-process log lines
  • retain valid JSON when a trailing log follows the payload
  • choose the last complete JSON value while preserving the existing failure shape

Tests

  • node --test test/stack.test.mjs (18 passed)
  • npm run check (20 passed)
  • nested, leading/trailing-log, multiple-value, and invalid-output parser matrix
  • git diff --check origin/main...HEAD

Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Devin Review

Comment thread bin/aas.mjs
Comment on lines +124 to +127
for (let start = 0; start < end; start += 1) {
if (!/^[\[{]/.test(lines[start].trim())) continue;
try {
return JSON.parse(line);
return JSON.parse(lines.slice(start, end).join("\n"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Truncated evaluations can authorize actions

When outer JSON is truncated, parseJsonOutput accepts a complete nested object as the entire response. A nested passed: true can permit a refund despite an unreadable policy evaluation.

Prompt for agents
Update parseJsonOutput in bin/aas.mjs so logged output extraction recognizes complete top-level JSON documents rather than trying every line-delimited substring. It must reject a valid nested object or array when its enclosing document is truncated, while still supporting pretty-printed top-level objects and arrays, leading or trailing logs, and multiple complete values with the last value selected. Add regression tests for truncated outer objects and arrays that contain valid nested values, including a nested object with passed: true.
Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@EauDoon
EauDoon merged commit 6657220 into main Aug 29, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant