Skip to content

fix(python): un-collapse three source files written through an escape layer - #202

Open
github-actions[bot] wants to merge 1 commit into
mainfrom
claude/fix-collapsed-python-sources
Open

fix(python): un-collapse three source files written through an escape layer#202
github-actions[bot] wants to merge 1 commit into
mainfrom
claude/fix-collapsed-python-sources

Conversation

@github-actions

@github-actions github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Three .py files in this repo have never been parseable. Each is normal Python up to a point, and then the entire remainder of the file sits on one line, with literal two-character \n, \" and \\ sequences instead of real newlines and quotes, plus a stray " at the very end:

File Collapsed at That line's length
containers/templates/agent-process/autonomous_agent.py line 155 14,245 chars
containers/templates/dev-base/agent-process/autonomous_agent.py line 155 14,245 chars
scripts/test_autonomous_execution.py line 148 3,852 chars
'            ) as response:\n                if response.status == 200:\n …
… asyncio.run(main())"

That is the signature of a file written through a JSON or shell escape layer that was never unescaped — whatever produced it emitted the string's escaped form as the file body.

Consequences: import autonomous_agent fails immediately, so the agent-process container template cannot start the process it exists to start, and scripts/test_autonomous_execution.py cannot run the test it is named for. Neither has ever worked.

The repair

A single left-to-right unescape (\n, \", \\, \t) of the collapsed line, dropping the trailing stray quote. Deliberately not codecs.decode(..., 'unicode_escape'), which would mangle the non-ASCII characters present in the test file.

The repair script refuses to write a file that does not ast.parse, so an unparseable result could not have been committed even by accident.

File Lines before → after
agent-process/autonomous_agent.py 154 → 516
dev-base/agent-process/autonomous_agent.py 154 → 516
scripts/test_autonomous_execution.py 147 → 217

The two autonomous_agent.py copies were byte-identical before and are byte-identical after — kept so deliberately, since they are the same template vendored twice.

Verification

Parsing is a low bar for a change this size, so the result was checked for sanity, not just validity:

  • All three pass compile().
  • The recovered code is correctly indented and coherent — the async with … as response: block closes properly, _setup_workspace is a well-formed coroutine, the file ends on if __name__ == '__main__': / asyncio.run(main()).
  • ruff check . --select E9,F63,F7,F82All checks passed for the whole repo, down from 19 errors.
  • The enforcing gate-lint from FuzeSDLC#217, run against this tree, exits 0 (it exits 1 on main).

How it survived

gate-lint ran ruff on every PR under set +e with a terminal exit 0, so all 19 errors were printed and discarded every time. Found by flipping that gate to enforcing in FuzeSDLC#217.

Note on this PR

Opened automatically as a draft by the stranded-branch detector between my push and my own create_pull_request call; marked ready for review and given its body here. The commit and branch are mine.

Related

Companion to FuzeSDLC#217. One of four real defects that flip exposed — the others are FuzeSocial#88, FuzePlan#211, and a missing import sys in FuzeInfra's tunnel-manager (delegated, not edited from here).

… layer

Three .py files have never been parseable. Each one is normal Python up to a
point, and then the entire remainder of the file sits on ONE line — 14,245
characters in autonomous_agent.py, 3,852 in test_autonomous_execution.py —
with literal two-character `\n`, `\"` and `\\` sequences instead of real
newlines and quotes, and a stray `"` at the very end. That is the signature
of a file written through a JSON or shell escape layer that was never
unescaped: whatever produced it emitted the string's ESCAPED form as the
file body.

Consequences: `python -c "import autonomous_agent"` fails immediately, so
the agent-process container template cannot start the process it exists to
start, and scripts/test_autonomous_execution.py cannot run the test it is
named for. Neither has ever worked.

Repaired by a single left-to-right unescape (`\n`, `\"`, `\\`, `\t`) of the
collapsed line, dropping the trailing stray quote. The repair script refuses
to write a file that does not `ast.parse`, so an unparseable result could not
have been committed even by accident. Recovered 362 real lines in each
autonomous_agent.py and 70 in the test.

The two autonomous_agent.py copies (agent-process and dev-base/agent-process)
were byte-identical before and are byte-identical after — deliberately kept
so, since they are the same template vendored twice.

Verified beyond parsing: all three pass `compile()`, the recovered code is
correctly indented and coherent (the `async with ... as response:` block, the
`_setup_workspace` coroutine, the `if __name__ == '__main__':` tail), and
`ruff check --select E9,F63,F7,F82` now reports "All checks passed" for the
whole repo, down from 19 errors.

Found by flipping gate-lint to enforcing in FuzeSDLC#217. Under the old
`set +e` … `exit 0` these 19 errors were printed and discarded on every run.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GaPa3JgrVNtWrGvqQEAEqv
@izzywdev
izzywdev marked this pull request as ready for review August 25, 2026 23:44
@izzywdev
izzywdev self-requested a review as a code owner August 25, 2026 23:44
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